Advertisement
Guest User

lab 2

a guest
Mar 14th, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. int led [6]={5,6,7,8,9,10};
  2. int i;
  3. int x;
  4.  
  5. // the setup routine runs once when you press reset:
  6. void setup() {                
  7.   pinMode(A1, INPUT);
  8.   for(int i=0;i<6;i++)
  9.     pinMode(i, OUTPUT);
  10. }
  11.  
  12.  
  13. // the loop routine runs over and over again forever:
  14. void loop() {
  15. x= analogRead(A1);
  16.   i=map(x,0,1023,0,6);  
  17.   proceso(i);
  18. }
  19.  
  20. void proceso(int i)
  21. {
  22.    
  23.   digitalWrite(led[i], HIGH);   // turn the LED on (HIGH is the voltage level)
  24.   //delay(10);               // wait for a second
  25.   digitalWrite(led[i], LOW);    // turn the LED off by making the voltage LOW
  26.   //delay(50);               // wait for a second
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement