CPP 199
Led button while By hightechrobo on 27th January 2024 07:00:16 AM
  1. /*
  2. Hightechrobo learn
  3. by Arian
  4. */
  5. #define button 4
  6. #define led 3
  7. void setup() {
  8.   // put your setup code here, to run once:
  9. pinMode(led,OUTPUT);
  10. pinMode(button,INPUT_PULLUP);
  11. }
  12. void loop() {
  13.   // put your main code here, to run repeatedly:
  14.  
  15.   if(digitalRead(button) == 0 and a == 0){
  16.   a = 1;
  17.  
  18.     while( digitalRead(button) == 0){
  19.           analogWrite(led,255);
  20.     }
  21.     }
  22.  
  23. else if(digitalRead(button) == 0 and a == 1){
  24.   a = 0;
  25.  
  26.     while(digitalRead(button) == 0){
  27.           analogWrite(led,0);
  28.     }
  29.    
  30.     }
  31.    
  32. }

Hightechrobo bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.