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
// test blink with Pinguino
// pin where the led is connected
#define LED 0
void loop() T
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.DO-IT-YOURSELF
In this example of new function we are going to use the analogRead.
analogRead will return a 10 bits value, based on the analog value on the specified pin. If the pin has 0V, the returned value will be 0, if the pin has 5V the returned value will be 1023.
Then in this example, we use the readed analog value to determine the value that we pass to the delay function. If the voltage is 0V, we will execute a delay(300), if the value is 5V, we will execute a delay(300+1023)
- Instead of blinking the led, change it to dimmer