EFA | 002 – Microcontrollers and Arduino Basics

Inspiration

Today’s Artists

Class Content

We go through the basics of working with the Arduino. See this separate page about it: Arduino Basics

I have also made a video explaining he setup process.

Example Done in Class

This is the code for the final example we ended up doing in class (4.11.2021)

int btnState;
int light;
void setup() {
  // put your setup code here, to run once:
  pinMode(9, OUTPUT);
  pinMode(2, INPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  btnState = digitalRead(2);
  light = analogRead(A0);
  Serial.println(light);
  if (btnState == HIGH) {
    analogWrite(9, light/4);
  }else{
     analogWrite(9,0);
  }
}