#92 Arduino C++ - Lesson 4 Controlling digital pins with digitalWrite()

preview_player
Показать описание
Lesson 4 explains how to use pinMode() and digitalWrite() to control outputs.
This is combined with the timing code from lesson 3.

For more information, code and circuit diagram visit
Рекомендации по теме
Комментарии
Автор

Great Thank you for sharing! Well done mate - NEW SUB 🙏🏻

shakejones
Автор

Question, do you need a resistor on every LED? Or could you put one Resistor between Ground and the return pin of the LED and just use one Resistor for the LED Section of the circuit? Just thinking it would make the circuit much simpler if this can be done, but don't want to fry LEDs in the process.

Of course, not sure yet if some more of this comes into play in the next lesson yet...

davidluckman
Автор

Thanks for the lesson. I do like the copy and paste idea, as often my sketches fail because of spelling mistakes. Tried this "homework" on several LEDS. I used this in my sketch.
Not sure who to give the thumbs up to, as it could be an amalgamation of several people. It uses the NOT (!) function to toggle the LED.

for (int i = 0; i < arraySize; i++) {
// Check if it's time to blink the LED
if (currentMillis - previousMillis[i] >= intervals[i]) {
// Save the last time the LED blinked
previousMillis[i] = currentMillis;

// Toggle the LED state
ledState[i] = !ledState[i];

// Update the LED
digitalWrite(ledPins[i], ledState[i]);
}
}

willsgrandad
join shbcf.ru