
Tutorial analogRead
reading analog value
The goal of this example is to read an analog value. Based on the value read, a led will blink faster or slower.
WHAT DO YOU NEED
SCHEMATIC
BOARD
In the schema you need a variable resistor connected to pin 15 and to 5V and GND.SOFTWARE
// test blink with Pinguino
#define PIC18F4550
// pin where the led is connected#define LED 0
void setup()
{
pinMode(LED,OUTPUT);
}
void loop() T
{
digitalWrite(LED,HIGH);
delay(300+analogRead(15));digitalWrite(LED,LOW);
delay(300+analogRead(15));
}
As this it's not the first pinguino example, we are going to suppose that you know what means the setup and loop functions, and why appears the #define PIC18F4550 directive.In...