Last update:
2018/06/11
12:25
odroid_go:arduino:03_blue_led_and_pwm https://wiki.odroid.com/odroid_go/arduino/03_blue_led_and_pwm?rev=1528687521
https://wiki.odroid.com/
Printed on 2023/05/05 21:45
Let's make the LED blinks permanently.
Open a new sketch by pressing the shortcut CTRL-N.
You're able to control that LED very easily.
The pin number for the LED is 2. Define that with Preprocessor.
First, we have to make the pin as output mode, use pinMode() function to do that.
#define PIN_BLUE_LED 2
void
setup
()
{
// put your setup code here, to run once:
pinMode
(
PIN_BLUE_LED
,
OUTPUT
);
}
void
loop
()
{
// put your main code here, to run repeatedly:
}
Now the pin is in ready.
You can write a signal in bits by using digitalWrite() function. Surely this function have to be in
loop() function to run repeatedly.
And give a delay() function to slow down the blink.
#define PIN_BLUE_LED 2
void
setup
()
{
// put your setup code here, to run once:
pinMode
(
PIN_BLUE_LED
,
OUTPUT
);
}
void
loop
()
{
// put your main code here, to run repeatedly:
digitalWrite
(
PIN_BLUE_LED
,
HIGH
);
delay
(
500
);
digitalWrite
(
PIN_BLUE_LED
,
LOW
);
delay
(
500
);
}
Press CTRL-U to compile and upload the sketch.
Then you can see the blue LED blinks.