Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- September 3, 2020
- Reddit basic c/c++ coding...
- */
- void setup() {
- // pinMode (2, INPUT); -----------------------> this is not correct, and won't work.
- // You cannot have a space after the keyword "pinmode".
- // The line below shows the correct way.
- pinMode(2, INPUT);
- pinMode(3, INPUT);
- pinMode(4, INPUT);
- pinMode(5, INPUT);
- digitalWrite(2, LOW);
- digitalWrite(3, LOW);
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- }
- void loop()
- {
- // if (digitalRead(2||3) = HIGH) ----------------> this is not correct, and won't work.
- // You can't evaluate two conditions this way because the digitalRead() command does not accept two arguments.
- // Also a comparison requires double equal signs ( == ). The single equals sign is for value assignment ( = ).
- // The line below shows the correct way.
- if ((digitalRead(2) == HIGH) || (digitalRead(3) == HIGH))
- {
- // digitalWrite(4 and 5 = HIGH); --------------> this is not correct, and won't work.
- // The digitalWrite() command only accepts two arguments, the pin number and the value to write.
- // The two lines below show the correct way.
- digitalWrite(4, HIGH);
- digitalWrite(5, HIGH);
- delay(1000);
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- }
- else {
- digitalWrite(4, LOW);
- digitalWrite(5, LOW);
- }
- }
- // the end
Advertisement
Add Comment
Please, Sign In to add comment