Skip to content

Instantly share code, notes, and snippets.

@thejevans
Last active February 18, 2019 17:54
Show Gist options
  • Save thejevans/6228626f9d99c359610ee7fe89290f15 to your computer and use it in GitHub Desktop.
Save thejevans/6228626f9d99c359610ee7fe89290f15 to your computer and use it in GitHub Desktop.
Makerspace_Workshop_1_Arduino_Intro
Link to presentation:
https://docs.google.com/presentation/d/1rklrRGW5udTUR9XmM4PtCNwZ1L_dxudQS08pqznV3J4/edit?usp=sharing
void setup() {
Serial.begin(9600);
Serial.println("Hello World!");
}
void loop() {
}
#define LED 4
void setup() {
Serial.begin(9600);
pinMode(LED,OUTPUT);
}
void loop() {
analogWrite(LED,0);
delay(1000);
analogWrite(LED,150);
delay(1000);
}
#define LED 4
#define SENSOR A0
void setup() {
Serial.begin(9600);
pinMode(LED,OUTPUT);
pinMode(SENSOR,INPUT);
}
void loop() {
analogWrite(LED,0);
delay(500);
Serial.println(analogRead(SENSOR));
analogWrite(LED,150);
delay(1000);
Serial.println(analogRead(SENSOR));
}
#define LED 4
#define SENSOR A0
#define THRESHOLD 30
void setup() {
Serial.begin(9600);
pinMode(LED,OUTPUT);
pinMode(SENSOR,INPUT);
}
void loop() {
int light_val = analogRead(SENSOR);
if(light_val < THRESHOLD) {
analogWrite(LED,150);
}
else {
analogWrite(LED,0);
}
Serial.println(analogRead(SENSOR));
}
#define LED 4
#define SENSOR A0
#define THRESHOLD 30
void setup() {
Serial.begin(9600);
pinMode(LED,OUTPUT);
pinMode(SENSOR,INPUT);
}
void loop() {
int light_val = analogRead(SENSOR);
analogWrite(LED,max(150-light_val*3,0));
Serial.println(analogRead(SENSOR));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment