juberth

Untitled

Sep 18th, 2013
1,422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1.  
  2. const int pinLatch = 2;
  3. const int pinReloj = 3;
  4. const int pinDato = 4;  
  5.  
  6. int led[pines] = {2,3,4};
  7. int valor=0;
  8. int i=0;
  9.  
  10.  
  11.  
  12. void setup ()
  13. {
  14.   Serial.begin(9600);
  15.   for (int i=0;i<pines;i++)
  16.   pinMode(led[i],OUTPUT);
  17. }
  18.  
  19.  
  20.  
  21. void loop()
  22. {
  23.   if(Serial.available() > 0)
  24.   {
  25.     valor = Serial.read();
  26.     activacion(valor);
  27.    
  28.    
  29.   }
  30. }
  31.  
  32. void activacion(int i)
  33. {
  34.   digitalWrite (pinLatch, LOW);
  35.   shiftOut (pinDato, pinReloj, MSBFIRST, valor);
  36.   digitalWrite (pinLatch, HIGH);  
  37.   delay(50);  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment