I have a school project and used a arduino Uno for prototyping. It worked fine on the arduino uno, but when I decided to change it to a arduino Nano 33 IoT it didn't
I connected all the same pins, but the motor now doesn't work, however the RGB's still work.
I have set it up in a way that pressing the button will cause the motor to go on, and pressing it again will turn it off. There are also some RGB's, but these are not connected to the motor in anyway.
Is there a solution or is it a problem with the board?
The code is below but only a small bottom part is important for my question
(I marked it with This part is important)
const int button = 9;
const int button1= 8;
const int button2= 7;
const int blue = 12;
const int red = 11;
const int green = 10;
int counter = 0;
int status = false;
int motor = 6;
int status2 = true;
void setup() {
pinMode(button, INPUT_PULLUP);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(motor, OUTPUT);
Serial.begin (9600);
}
void loop() {
int buttonState;
buttonState = digitalRead(button);
if (buttonState == LOW) {
counter++;
delay(100);
}
else if (counter == 0) {
digitalWrite(red, HIGH);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
}
else if (counter == 1) {
digitalWrite(red, HIGH);
digitalWrite(green, HIGH);
digitalWrite(blue, LOW);
}
else if (counter == 2) {
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
digitalWrite(blue, LOW);
}
else if (counter == 3) {
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
digitalWrite(blue, HIGH);
}
else if (counter == 4) {
digitalWrite(red, LOW);
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);
}
else if (counter == 5) {
digitalWrite(red, HIGH);
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);
}
else {
counter = 0;
}
// This part is important
do {
int status1;
status1 = digitalRead(button2);
if (status1 == 0){
status2 = !status2;
delay (100);}
if (status2 == 0){
digitalWrite (motor, HIGH);
}
else { digitalWrite (motor, LOW);
}
// until here
if (digitalRead(button1) == 0){
status=!status;
delay (100);
}
if (status ==0){
digitalWrite(red, LOW);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
}
Serial.print(status2);
Serial.print("/");
Serial.print(digitalRead(button2));
Serial.print("/");
Serial.println(digitalRead(motor));
delay (100);
} while (status == 0);
}
Sorry in advance for my probably bad code and bad schematic, I'm still learning and any advise would help ![]()
Thank you in advance
arduino schematic doesnt work.pdf (1.52 MB)
