Last active
February 18, 2019 17:54
-
-
Save thejevans/6228626f9d99c359610ee7fe89290f15 to your computer and use it in GitHub Desktop.
Makerspace_Workshop_1_Arduino_Intro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Link to presentation: | |
https://docs.google.com/presentation/d/1rklrRGW5udTUR9XmM4PtCNwZ1L_dxudQS08pqznV3J4/edit?usp=sharing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
Serial.begin(9600); | |
Serial.println("Hello World!"); | |
} | |
void loop() { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LED 4 | |
void setup() { | |
Serial.begin(9600); | |
pinMode(LED,OUTPUT); | |
} | |
void loop() { | |
analogWrite(LED,0); | |
delay(1000); | |
analogWrite(LED,150); | |
delay(1000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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