+ 1

Hey Everyone! Please help me, it's so serious! I would like to make a code for a shutter control in C++, here's the code:

void setup() { Serial.begin(9600); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); //digitalWrite(11, HIGH); } void loop() { commandState = analogRead(A0); Serial.println(commandState); if(commandState == 0 && commandState <20){ digitalWrite(11, HIGH); digitalWrite(10, LOW); digitalWrite(9, LOW); digitalWrite(8, LOW); } else if(commandState > 683 && commandState < 723) { digitalWrite(11, LOW); digitalWrite(10, HIGH); digitalWrite(9, LOW); digitalWrite(8, LOW); } else if(commandState > 94 && commandState < 134) { digitalWrite(11, LOW); digitalWrite(10, LOW); digitalWrite(9, HIGH); digitalWrite(8, LOW); } else if(commandState > 394 && commandState < 434) { digitalWrite(11, LOW); digitalWrite(10, LOW); digitalWrite(9, LOW); digitalWrite(8, HIGH); } delay(50); }

11th Jun 2018, 7:06 PM
Benedek Szabó
Benedek Szabó - avatar
1 Odpowiedź
+ 2
Assuming you're trying to code on Arduino, I think you need to put 'int' before the first commandState (right after loop(){) to declare. if it's not an compile issue, you could explain problems more.
14th Jun 2018, 9:40 AM
Ryu
Ryu - avatar