kartonman

Bunza Building Lights

Aug 31st, 2021
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #define numleds 15
  2. byte ledpins [ ] = { 0,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 } ;
  3. void setup( ) {
  4. for ( int i=1; i <= numleds; i++ ) {
  5. pinMode ( ledpins [ i ], OUTPUT) ;
  6. digitalWrite ( ledpins [ i ] , HIGH) ;
  7. }
  8. pinMode (2,INPUT); // Pin 2 will be the control pin for this lighting group
  9. digitalWrite (2,HIGH); //This turns the Pull up ON
  10. }
  11. void loop ( ) {
  12. digitalWrite ( ledpins [ random ( 0, numleds+1 ) ], lightsw ( ) ) ;
  13. delay ( 900 ) ;
  14. }
  15. boolean lightsw ( ) {
  16. if (digitalRead(2) == LOW) return LOW; //If the group control pin is LOW ALL lights
  17. // will eventually turn OFF
  18. if ( random (0,100) > 40 ) return LOW ;
  19. else return HIGH ;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment