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,45 @@
|
|||
/*
|
||||
SparkFun Inventor’s Kit
|
||||
Circuit 4B - Temperature Sensor
|
||||
|
||||
The LCD will display readings from a temperature sensor in degrees Celsius and Fahrenheit.
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
#include <LiquidCrystal.h> //the liquid crystal library contains commands for printing to the display
|
||||
LiquidCrystal lcd(13, 12, 11, 10, 9, 8); // tell the RedBoard what pins are connected to the display
|
||||
|
||||
float voltage = 0; //the voltage measured from the TMP36
|
||||
float degreesC = 0; //the temperature in Celsius, calculated from the voltage
|
||||
float degreesF = 0; //the temperature in Fahrenheit, calculated from the voltage
|
||||
|
||||
void setup() {
|
||||
|
||||
lcd.begin(16, 2); //tell the lcd library that we are using a display that is 16 characters wide and 2 characters high
|
||||
lcd.clear(); //clear the display
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
voltage = analogRead(A0) * 0.004882813; //convert the analog reading, which varies from 0 to 1023, back to a voltage value from 0-5 volts
|
||||
degreesC = (voltage - 0.5) * 100.0; //convert the voltage to a temperature in degrees Celsius
|
||||
degreesF = degreesC * (9.0 / 5.0) + 32.0; //convert the voltage to a temperature in degrees Fahrenheit
|
||||
|
||||
lcd.clear(); //clear the LCD
|
||||
|
||||
lcd.setCursor(0, 0); //set the cursor to the top left position
|
||||
lcd.print("Degrees C: "); //print a label for the data
|
||||
lcd.print(degreesC); //print the degrees Celsius
|
||||
|
||||
lcd.setCursor(0, 1); //set the cursor to the lower left position
|
||||
lcd.print("Degrees F: "); //Print a label for the data
|
||||
lcd.print(degreesF); //print the degrees Fahrenheit
|
||||
|
||||
delay(1000); //delay for 1 second between each reading (this makes the display less noisy)
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue