SHARE
TWEET

Untitled

carcyn Dec 5th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * Turning on two leds with a push button
  3.  * Carcyn M.R. Coleman
  4.  * 12/4/19
  5.  * Version2
  6.  */
  7. int ledPin=8;
  8. int buttonPin=10;
  9. int readValue;
  10. int ledPin2=2;
  11. int count=0;
  12. int ledPin3=5;
  13.  
  14.  
  15. void setup() {
  16.    pinMode(buttonPin, INPUT) ;
  17.    pinMode(ledPin, OUTPUT) ;
  18.    pinMode(ledPin2, OUTPUT) ;
  19.     pinMode(ledPin3, OUTPUT) ;
  20.    Serial.begin(9600) ;
  21.    digitalWrite(ledPin,HIGH);
  22.     digitalWrite(ledPin2,HIGH);
  23.     digitalWrite(ledPin3,HIGH);
  24.    delay(100);  
  25.    digitalWrite(ledPin,LOW);
  26.    digitalWrite(ledPin2,LOW);
  27.    digitalWrite(ledPin3,LOW);
  28. }
  29.  
  30. void loop() {
  31.   readValue= digitalRead(buttonPin) ;
  32.   delay(100) ;
  33.   if(readValue ==1)
  34. {
  35.   count++;
  36.     Serial.println(count) ;
  37. }
  38.  
  39.   if (count==1 )
  40. {
  41.   digitalWrite(ledPin,HIGH) ;
  42.   digitalWrite(ledPin2,LOW) ;
  43.   digitalWrite(ledPin3,LOW) ;
  44. }
  45.   if (count==2)
  46.   {
  47.   digitalWrite(ledPin,LOW) ;
  48.   digitalWrite(ledPin2,HIGH) ;
  49.   digitalWrite(ledPin3,LOW);
  50.   }
  51.   if (count==3)
  52.   {
  53.   digitalWrite(ledPin,LOW) ;
  54.   digitalWrite(ledPin2,LOW) ;
  55.   digitalWrite(ledPin3,HIGH) ;
  56.   }
  57.  if (count==4)
  58.   {
  59.   digitalWrite(ledPin,HIGH) ;
  60.   digitalWrite(ledPin2,HIGH) ;
  61.   digitalWrite(ledPin3,HIGH) ;
  62.   }
  63. if (count==5)
  64.  {
  65.   digitalWrite(ledPin,LOW) ;
  66.   digitalWrite(ledPin2,LOW) ;
  67.   digitalWrite(ledPin3,LOW) ;
  68.   count=0;
  69.  }
  70. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top