Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Arduino - LED 'brightness' question

2 posters

Go down  Message [Page 1 of 1]

1Arduino - LED 'brightness' question Empty Arduino - LED 'brightness' question Fri Mar 11, 2022 5:34 pm

irwinger



I was doing some Arduino projects 5 years ago and now have more time to do more. I am relearning about the Arduino and using SimulIDE for code and circuit development as I travel.

When I setup the an Arduino Nano and upload the example Blink - the onboard LED changes from bright yellow to dark blue (the captured image shows the Blink program running and the LED 'on'). When I change the circuit and the code as below:
Arduino - LED 'brightness' question Screen11
Code:
   int LED1 = 13;
  int SW1 = 12;
  int LED2 = 11;

void setup() {
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(SW1, INPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED1, HIGH);  
  digitalWrite(LED2, LOW);    
  int varSW = digitalRead(SW1);
  if (varSW == 1) {
    digitalWrite(LED1, LOW);
/   digitalWrite(LED2, HIGH);
  }
}

Here is an image of the LEDs when they are 'on':
Arduino - LED 'brightness' question Screen12

Is this a bug in SimulIDE? Or is there a problem with my circuit or my code?

Thank you!

2Arduino - LED 'brightness' question Empty Re: Arduino - LED 'brightness' question Sat Mar 12, 2022 9:17 pm

arcachofo

arcachofo

In your code those leds are continuously switching on and off.

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum