- Starting the board like figure 1.
figure 1 - DANGER. Smelled burn from the potentiometer with layout in figure 2. Was trying to save space by placing the resistor right next to the board… (what was I thinking) Don’t do this. Also the port lost connection with the board once the upload was completed. I thought there might be a conflict between my USB keyboard and the Arduino so I even unplugged my usb keyboard. But I guess the real reason may be that I shorted the port for USB connection or the entire board.
figure 2 - Moving the resistor and LED downwards. (figure 3)
figure 3 - Coding went smoothly. Here is the final code.
const int ledPin = 9;
int analogValue = 0;
int brightness = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}void loop() {
// put your main code here, to run repeatedly:
analogValue = analogRead(A0);
brightness = analogValue / 4;
analogWrite(ledPin, brightness);
Serial.println(brightness);
} - Here’s the final result. (figure 4 & figure 5) note the position of the turn button.
figure 4 figure 5
Leave a Reply