Bi’s Arduino Homework 2

int button = 2;
int led = 9;
int fadeAmount = 5;
int brightness = 0;

void setup()
{
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
  Serial.begin(9600);
}

void loop()

{
  Serial.println(brightness);
 
  int button_pressed = digitalRead(button);
  if ((brightness + fadeAmount = 0) && !button_pressed)
    brightness -= fadeAmount;

  analogWrite(led, brightness);
  delay(20);
}

One thought on “Bi’s Arduino Homework 2”

Comments are closed.

Discover more from Making Studio

Subscribe now to keep reading and get access to the full archive.

Continue reading