1 / 3

Warmup – 21 FEB2012

Warmup – 21 FEB2012. Arduino. This one is for practice . I have paper if you need it .

sorley
Download Presentation

Warmup – 21 FEB2012

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. Warmup – 21FEB2012 Arduino This one is for practice. I have paper if you need it. Create a function in C that takes as its argument an Arduino pin number and returns HIGH or LOW depending on the digital value of the pin state (HIGH or LOW, respectively). In other words, if the digital value of Arduino pin 3 is LOW, your function returns LOW, else if the pin is HIGH, your function returns HIGH. Pxn Px0

  2. Solution – Arduino Style intdig_test ( intpin_no ) { if ( ( (pin_no >= 0) && (pin_no <= 19) ) ) { return (digitalRead( pin_no ) ); } else { return (-1); } }

  3. Solution – PORT Style intdig_test ( intpin_no ) { if ( ( (pin_no >= 0) && (pin_no <= 19) ) ) { if pin_no in 0-7, then PORTD if pin_no in 8-13, then PORTB if pin_no in 14-19, then PORTC return (digitalRead( pin_no ) ); } else { return (-1); } }

More Related