Advertisement
Guest User

task1

a guest
Nov 22nd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. int ledpin =11;
  2. int x;
  3. int y;
  4. int i;
  5. int z;
  6. bool ledstate = LOW;
  7. unsigned long previousmillis = 0;
  8. const long interval = 500;
  9. unsigned long currentmillis;
  10.  
  11. void Blink(){
  12. ledstate=!ledstate;
  13. digitalWrite(ledpin, ledstate);
  14.  
  15. }
  16.  
  17.  
  18. void setup() {
  19. // put your setup code here, to run once:
  20. Serial.begin(9600);
  21. pinMode(ledpin, OUTPUT);
  22. }
  23.  
  24. void loop() {
  25. // put your main code here, to run repeatedly:
  26. if (Serial.available()>0){
  27. x=Serial.read();
  28. if (x>=49){
  29. y=x-49;
  30. for (i=0; i>=y; i++){
  31. currentmillis = millis();
  32. z=currentmillis-previousmillis;
  33. if (z>=interval){
  34. Blink();}
  35. previousmillis=currentmillis;
  36. }}}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement