On branch main
Your branch is up to date with 'origin/main'. Changes to be committed: modified: README.md new file: examples/SIK_Circuit_1A-Blink/SIK_Circuit_1A-Blink.ino new file: examples/SIK_Circuit_1B-Potentiometer/SIK_Circuit_1B-Potentiometer.ino new file: examples/SIK_Circuit_1C-Photoresistor/SIK_Circuit_1C-Photoresistor.ino new file: examples/SIK_Circuit_1D-RGBNightlight/SIK_Circuit_1D-RGBNightlight.ino new file: examples/SIK_Circuit_2A-Buzzer/SIK_Circuit_2A-Buzzer.ino new file: examples/SIK_Circuit_2B-DigitalTrumpet/SIK_Circuit_2B-DigitalTrumpet.ino new file: examples/SIK_Circuit_2C-SimonSays/SIK_Circuit_2C-SimonSays.ino new file: examples/SIK_Circuit_3A-Servo/SIK_Circuit_3A-Servo.ino new file: examples/SIK_Circuit_3B-DistanceSensor/SIK_Circuit_3B-DistanceSensor.ino new file: examples/SIK_Circuit_3C-MotionAlarm/SIK_Circuit_3C-MotionAlarm.ino new file: examples/SIK_Circuit_4A-LCDHelloWorld/SIK_Circuit_4A-LCDHelloWorld.ino new file: examples/SIK_Circuit_4B-TemperatureSensor/SIK_Circuit_4B-TemperatureSensor.ino new file: examples/SIK_Circuit_4C-DIYWhoAmI/SIK_Circuit_4C-DIYWhoAmI.ino new file: examples/SIK_Circuit_5A-MotorBasics/SIK_Circuit_5A-MotorBasics.ino new file: examples/SIK_Circuit_5B-RemoteControlRobot/SIK_Circuit_5B-RemoteControlRobot.ino new file: examples/SIK_Circuit_5C-AutonomousRobot/SIK_Circuit_5C-AutonomousRobot.ino new file: library.properties new file: src/SIK.h
This commit is contained in:
parent
35e1115a5c
commit
0cf48bdc8d
19 changed files with 1654 additions and 2 deletions
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
SparkFun Inventor’s Kit
|
||||
Circuit 1C-Photoresistor
|
||||
|
||||
Use a photoresistor to monitor how bright a room is, and turn an LED on when it gets dark.
|
||||
|
||||
This sketch was written by SparkFun Electronics, with lots of help from the Arduino community.
|
||||
This code is completely free for any use.
|
||||
|
||||
View circuit diagram and instructions at: https://learn.sparkfun.com/tutorials/sparkfun-inventors-kit-experiment-guide---v41
|
||||
Download drawings and code at: https://github.com/sparkfun/SIK-Guide-Code
|
||||
*/
|
||||
|
||||
int photoresistor = 0; //this variable will hold a value based on the brightness of the ambient light
|
||||
int threshold = 750; //if the photoresistor reading is below this value the the light will turn on
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600); //start a serial connection with the computer
|
||||
|
||||
pinMode(13, OUTPUT); //set pin 13 as an output that can be set to HIGH or LOW
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
//read the brightness of the ambient light
|
||||
photoresistor = analogRead(A0); //set photoresistor to a number between 0 and 1023 based on how bright the ambient light is
|
||||
Serial.println(photoresistor); //print the value of photoresistor in the serial monitor on the computer
|
||||
|
||||
//if the photoresistor value is below the threshold turn the light on, otherwise turn it off
|
||||
if (photoresistor < threshold) {
|
||||
digitalWrite(13, HIGH); // Turn on the LED
|
||||
} else {
|
||||
digitalWrite(13, LOW); // Turn off the LED
|
||||
}
|
||||
|
||||
delay(100); //short delay to make the printout easier to read
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue