1 / 7

Cascade switching of an LED

Cascade switching of an LED. EAS 199B Winter 2011. Digital I/O pin to switch LED. Transistor switch for LED. Transistor to Relay switch for LED. Compare switching circuits. Code to turn on pins. int npin = 3; // number of pins

ania
Download Presentation

Cascade switching of an LED

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cascade switching of an LED EAS 199B Winter 2011

  2. Digital I/O pin to switch LED

  3. Transistor switch for LED

  4. Transistor to Relay switch for LED

  5. Compare switching circuits

  6. Code to turn on pins int npin = 3; // number of pins int LED_pin[] = {4,5,6}; // array of pins for digital output void setup() { for ( int i=0; i<npin; i++ ) { // arrays are zero offset pinMode( LED_pin[i], OUTPUT ); } } void loop() { int i; for ( i=0; i<npin; i++ ) { digitalWrite( LED_pin[i], HIGH); } delay(1000); for (i=0; i<npin; i++ ) { digitalWrite( LED_pin[i], LOW); } delay(1000); }

  7. Code without loops int LED_pin1=4, LED_pin2=5, LED_pin3=6; void setup() { pinMode( LED_pin1, OUTPUT ); pinMode( LED_pin2, OUTPUT ); pinMode( LED_pin3, OUTPUT ); } void loop() { digitalWrite( LED_pin1, HIGH); digitalWrite( LED_pin2, HIGH); digitalWrite( LED_pin3, HIGH); delay(1000); digitalWrite( LED_pin1, LOW); digitalWrite( LED_pin2, LOW); digitalWrite( LED_pin3, LOW); delay(1000); }

More Related