Hi everyone, I'm your Manitesla.In the last post, we learned how to turn Arduino pins on and off with the Arduino digitalWrite command. This command is best if you only want 0 or 5 volts. In this post, I'll show how you can get the in-between values (0-5)by using the analogWrite command. In the upcoming post, I will in detail how analogWrite works, but this present post gets you started, and shows you how to control the brightness of an LED. U can watch the video below to learn how to control led brightness.
Arduino AnalogWrite Code:
int ledPin = 9; // LED is connected to pin 9th pin
void setup() {
pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop() {
analogWrite(ledPin, 255);//analogWrite values from 0 to 255
}
0 comments:
Post a Comment
Ask Something