This week has been a hectic one. However I was able to do the labs. For the first example this is the code.
const int transistorPin = 9;// connected to the base of the transistor
void setup() {
// put your setup code here, to run once:
pinMode(transistorPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(transistorPin, HIGH);
delay(1000);
digitalWrite(transistorPin, LOW);
delay(1000);
}
Here’s how I connected it to make it work by following the lab.

I recorded a video of the functionality! It was just turning on and off with a delay.
In the following exercise, I was able to control it with a potentiometer. This is the code for it.
const int transistorPin = 9;// connected to the base of the transistor
void setup() {
// put your setup code here, to run once:
pinMode(transistorPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int sensorValue = analogRead(A0);// read potentiometer
delay(30);
int outputValue = map(sensorValue, 0, 1023, 0, 255);// map the sensor value from 0 to 255
analogWrite(transistorPin, outputValue);
}
Ceren and I did these labs together. This was a valuable collaboration because we did help each other each time something in our circuit or code wasn’t working properly. That allowed us to achieve these nicely.
The second lab we did was the driver motor one. Because any of us had a lamp, we couldn’t try the lamp section. We ran out of time to get one. However we managed to make the motor driver work properly. It was a little bit overwhelming at first because the amount of cables, but it was really possible to read and make it work. Here’s the code for the second lab.
const int switchPin = 2;
const int motor1Pin = 3;
const int motor2Pin = 4;
const int pwmPin = 5;
void setup() {
// put your setup code here, to run once:
pinMode(switchPin, INPUT);
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
pinMode(pwmPin, OUTPUT);
digitalWrite(pwmPin, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(switchPin) == HIGH) {
digitalWrite(motor1Pin, LOW);
digitalWrite(motor2Pin, HIGH);
} else {
digitalWrite(motor1Pin, HIGH);
digitalWrite(motor2Pin, LOW);
}
}
Here’s also the video of it working! I got confused at first because I wasn’t sure the pins between the Motor Driver stated in the lab and the Adafruit one were the same. However, it worked as intended. We found an inconsistency between the schematic and the diagram. We find that the schematic could have been different and wrong because by following it, we weren’t able to make it work, but by following the diagram we succeeded.