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