Use the ‘examples’ from Arduino, it can be useful to look at them to make sure your code is working well
Turn on autofill
On/off is digitalWrite
High is giving it voltage, low (ground) is not giving it voltage
This would dim, because it’s moving so fast per millisecond
digitalWrite(4, HIGH);
digitalWrite(4, LOW);
This would be 2 seconds, not one, because there’s two delays
digitalWrite(4, HIGH);
delay(1000);
digitalWrite(4, LOW);
delay(1000);
How to get the LED turning on in turns and then stop
digitalWrite(3, HIGH);
delay (1000);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
delay(1000);
digitalWrite(4, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
delay(1000);
Variable is written as int, in variable you put = sign
#define is not a function, so don’t put = sign next to it, but it could act similar to a function
#define redLEDpin 3
#define yellowLEDPin 4
int delayAmount = 1;
void setup() {
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
delayAmount ++;
digitalWrite(3, HIGH);
delay (delayAmount);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
delay(delayAmount);
digitalWrite(4, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
delay(delayAmount);
}
long type of integer, giving it more memory to store, and it remembers between numbers, a short integer,
pull down resistor is a resistor that pulls things into ground, Arduino already has pull up resistors usually
to make something, something that it’s not, use !