Movatterモバイル変換


[0]ホーム

URL:


511 views

Arduino: Arduino lcd

The document provides code and instructions for three Arduino projects using an LCD screen:1) A "Hello World" display that prints text to the LCD screen. 2) A weather station that reads temperature and humidity from a sensor and displays the readings.3) An optional "Magic 8 Ball" project that displays random answers when shaken.

Embed presentation

Downloaded 15 times
Arduino: LCDDiagrams & CodeBrown County LibraryProject 01: Hello, World!Components needed: Arduino Uno board breadboard 16 jumper wires 16x2 LCD screen 10k potentiometer
5/2018Brown County Library/*LCD 01 : Hello World!Source: Code adapted from the Arduino.cc Hello World Tutorial(https://www.arduino.cc/en/Tutorial/HelloWorld)and Adafruit Arduino - Lesson 11. LCD Displays (https://learn.adafruit.com/adafruit-arduino-lesson-11-lcd-displays-1)*/#include <LiquidCrystal.h> // indicate that we want to use the Liquid Crystal library// initialize the library by associating any needed LCD interface pin// with the Arduino pin number that it is connected to// RS EN D4 D5 D6 D7LiquidCrystal lcd(7, 8, 9, 10, 11, 12);void setup() {lcd.begin(16, 2); // set up the LCD's number of columns and rowslcd.print("hello, world!"); // print a message to the LCD}void loop() {lcd.setCursor(0, 1); // set the cursor to column 0, row 1 (row 1 is the second row as counting begins with 0)lcd.print(millis() / 1000); // print the number of seconds since reset}
5/2018Brown County LibraryProject 02: Weather StationComponents needed: Arduino Uno board breadboard 19 jumper wires 16x2 LCD screen 10k potentiometer DHT11 temperature and humidity sensor
5/2018Brown County Library/*LCD 02 : Weather StationSource: Code adapted from the Arduino Project Handbook (Geddes, 2016) andladyada's DHT humidity/temperature sensors testing sketch (https://learn.adafruit.com/dht?view=all)*/#include <LiquidCrystal.h> // call the Liquid Crystal library#include <DHT.h> // call the DHT libraryconst int DHTPIN = 3; // pin connected to DHTconst int DHTTYPE = DHT11; // set the type of sensor// initialize the Liquid Crystal library by associating any needed LCD interface pin// with the Arduino pin number that it is connected to// RS E D4 D5 D6 D7LiquidCrystal lcd(7, 8, 9, 10, 11, 12);// initialize the DHT library by telling it the pin and sensor type// pin sensor typeDHT dht(DHTPIN, DHTTYPE);void setup() {dht.begin(); // start the DHT sensorlcd.begin(16, 2); // set up the LCD's number of columns and rows}void loop() {float h = dht.readHumidity(); // get a humidity readingfloat t = dht.readTemperature(); // get a temperature readingt = t * 9 / 5 + 32; // change temp reading from Celsius to Fahrenheitif (isnan(t) || isnan(h)) { // check that DHT sensor is workinglcd.setCursor(0, 0); // set the cursor to column 0, row 0lcd.print("Failed to read from DHT"); // if DHT is not working, display this} else { // otherwise show the readings on the screenlcd.clear();lcd.setCursor(0, 0); // set the cursor to column 0, row 0// display humidity readinglcd.print("Humidity: ");lcd.print(h);lcd.print("%");lcd.setCursor(0, 1); // set the cursor to column 0, row 1// display temperature readinglcd.print("Temp: ");lcd.print(t);lcd.print("f");}delay(1000); // stabilizes the LCD screen}
5/2018Brown County LibraryIdeas to Build OnBuild an electronic Magic 8 Ball - ask a question and get an answer when you gently tap or shake yourbreadboard!See page 6 of this document.Try to beat a reaction timer - how quickly can you press a button when a RGB LED flashes red?See page 9 of this document.https://learn.sparkfun.com/tutorials/sik-experiment-guide-for-arduino---v33/experiment-12-driving-a-motorBuild your own time clock, complete with buttons to set the hour and minute!Note: The diagram for this project is a bit confusing – it make take some critical thinking to come up with yourown setup.https://www.hackster.io/Annlee_Fores/simple-arduino-digital-clock-without-rtc-7d4303Learn MoreWant to learn more about how LCD screens and Arduino Libraries work? Try these resources:Adafruit Arduino Lesson 11: LCD Displays Part 1. Simon Monk.https://learn.adafruit.com/adafruit-arduino-lesson-11-lcd-displays-1?view=allAdafruit Arduino Lesson 12: LCD Displays Part 2. Simon Monk.https://learn.adafruit.com/adafruit-arduino-lesson-12-lcd-displays-part-2?view=allAdafruit Tips, Tricks & Techniques: Arduino Libraries. Lady Ada and Tyler Cooper.https://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduino-librariesAdafruit Character LCDs OverView. Lady Ada and Tony DiCola.https://learn.adafruit.com/character-lcds?view=allArduino – Hello World! https://www.arduino.cc/en/Tutorial/HelloWorldArduino – Libraries. https://www.arduino.cc/en/Reference/LibrariesArduino Project Handbook. Mark Geddes. 2016. Pg. 102-132.Exploring Arduino: Tools and Techniques for Engineering Wizardry. Jeremy Blum. 2013. Pg. 199-219.Sparkfun SIK Experiment Guide for Arduino V4.0 – Circuit 4A: LCD “Hello World!”.https://learn.sparkfun.com/tutorials/sparkfun-inventors-kit-experiment-guide---v40/circuit-4a-lcd-hello-world
5/2018Brown County LibraryExtra Project: Magic 8 BallComponents needed: Arduino Uno board breadboard 19 jumper wires 16x2 LCD screen 10k potentiometer 220 ohm resistor Tilt switch (four leg)
5/2018Brown County Library/*LCD Extra Project : Magic 8 BallSource: Code adapted from the Arduino Projects Book (Fitzgerald, Shiloh & Igoe, 2012)and Arduino Project Handbook (Geddes, 2016)*/#include <LiquidCrystal.h>LiquidCrystal lcd(12, 11, 5, 4, 3, 2);const int switchPin = 6;int switchState = 0;int prevSwitchState = 0;int reply;void setup() {// put your setup code here, to run once:lcd.begin(16, 2);pinMode(switchPin,INPUT);lcd.print("Ask the");lcd.setCursor(0,1);lcd.print("Crystal Ball!");// if analog input pin 0 is unconnected, random analog// noise will cause the call to randomSeed() to generate// different seed numbers each time the sketch runs.// randomSeed() will then shuffle the random function.randomSeed(analogRead(0));}void loop() {// put your main code here, to run repeatedly:switchState = digitalRead(switchPin);if (switchState != prevSwitchState) {if (switchState == LOW) {reply = random(8);lcd.clear();lcd.setCursor(0, 0);lcd.print("The ball says:");lcd.setCursor(0, 1);switch(reply){case 0:lcd.print("Yes");break;case 1:
5/2018Brown County Librarylcd.print("Most likely");break;case 2:lcd.print("Certainly");break;case 3:lcd.print("Outlook good");break;case 4:lcd.print("Unsure");break;case 5:lcd.print("Ask a Librarian");break;case 6:lcd.print("Doubtful");break;case 7:lcd.print("No");break;}}}prevSwitchState = switchState;}
5/2018Brown County LibraryExtra Project: Reaction TimerComponents needed: Arduino Uno board breadboard 25 jumper wires 16x2 LCD screen 10k potentiometer 4 x 220 ohm resistors Piezo buzzer RGB LED (common cathode) Push button
5/2018Brown County Library/*LCD Extra Project : Reaction TimerSource: Code adapted from the Arduino Project Handbook (Geddes, 2016)Originally created by Steven De Lannoyhttp://www.wingbike.nlUsed a RGB LED with a common anode (3 cathodes: R, G, B)*/#include <LiquidCrystal.h>LiquidCrystal lcd(12, 11, 5, 4, 3, 2);int LEDR = 8; // Pin connected to red LEDint LEDB = 6; // Pin connected to blue LEDint LEDGr = 7; // Pin connected to green LEDint Button = 9; // Pin connected to pushbuttonint COLOR; // Variable colorint Beep;int PSE; // Variable pauseint TME; // Timeint RTME = 0; // Reaction timevoid setup() {lcd.begin(16, 2);pinMode(LEDR, OUTPUT); // Set LED pins as outputpinMode(LEDB, OUTPUT);pinMode(LEDGr, OUTPUT);pinMode(Button, INPUT); // Set pushbutton as inputdigitalWrite(LEDR, LOW); // Switch on all LED colorsdigitalWrite(LEDB, LOW);digitalWrite(LEDGr, LOW);}void loop() {lcd.clear(); // Clear screenlcd.print("Hold Button to"); // Display message on LCD screenlcd.setCursor(0, 1); // Move to second linelcd.print("start.");while (digitalRead(Button) == LOW) { // Test does not start until// button is pushed (and held)tone(13, 1200, 30);delay(1400);noTone(13);}lcd.clear();digitalWrite(LEDR, HIGH); // Switch off start lightdigitalWrite(LEDB, HIGH);digitalWrite(LEDGr, HIGH);randomSeed(analogRead(0)); // Random noise from pin 0COLOR = random(1, 4); // Generate random colorPSE = random(500, 1200); // Set random pause duration between lights// Repeat this loop while color is green or blue AND pushbutton// is heldwhile (COLOR != 1 && digitalRead(Button) == HIGH) {digitalWrite(LEDGr, HIGH);digitalWrite(LEDB, HIGH);delay(PSE);randomSeed(analogRead(0));Beep = random(1, 4); // Select random beep from buzzer// (buzzer beeps 1 in 3 times)PSE = random(750, 1200); // Select random pause duration between// lights (to increase surprise effect)if (Beep == 1) {tone(13, 1600, 350);
5/2018Brown County Librarydelay(750);noTone(13);}if (COLOR == 2) {digitalWrite(LEDGr, LOW);}if (COLOR == 3) {digitalWrite(LEDB, LOW);}delay(PSE);randomSeed(analogRead(0));COLOR = random(1, 4); // Select random color}// Execute this loop if color is redif (COLOR == 1 && digitalRead(Button) == HIGH) {digitalWrite(LEDGr, LOW);digitalWrite(LEDB, LOW);delay(50);TME = millis(); // Record time since program has starteddigitalWrite(LEDR, HIGH);while (digitalRead(Button) == HIGH) { // Runs until button is// released, recording the// reaction timedelay(1);}lcd.display();RTME = millis() - TME; // Reaction time in millisecondslcd.print("Reaction Time:"); // Display on LCD screenlcd.setCursor(0, 1);lcd.print(RTME);}// Execute if color is NOT red but the pushbutton is releasedif (COLOR != 1) {lcd.print("Released too");lcd.setCursor(0, 1); // Move to second linelcd.print("soon!!!");tone(13, 3000, 1500);delay(500);noTone(13);}// Test does not restart until the button is pushed oncewhile (digitalRead(Button) == LOW) {delay(10);}digitalWrite(LEDR, LOW); // Reset all lights to begin againdigitalWrite(LEDB, LOW);digitalWrite(LEDGr, LOW);lcd.clear();lcd.print("Hold Button to");lcd.setCursor(0, 1);lcd.print("start.");int Time = 0;delay(1000);}

Recommended

PPTX
Arduino
PPT
Arduino presentation by_warishusain
PDF
Arduino presentation
ODP
Introduction to Arduino
PPTX
Arduino
PPTX
Arduino
PPTX
Introduction to Arduino Hardware and Programming
PPSX
Aircraft Anti collision system using ZIGBEE Communication
PDF
Programmable logic controller - Siemens S7-1200
PDF
Report on arduino
PPTX
Introduction to the Arduino
PDF
Arduino: Practicas con Arduino
PDF
Programación de autómatas PLC OMRON CJ/CP1
PDF
InTouch HMI SCADA
DOCX
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
PPTX
Lesson sample introduction to arduino
PDF
Introduction to AutoCAD
PPTX
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
PPTX
Simulación de Semáforo
PPT
PDF
Manual del sistema del controlador programable S7-200 SMART
PPTX
116. 03_INTRODUCTION OF SIMULIDE.pptx
PPTX
Introduction to Arduino
PDF
Auto Cad tutorial
PPT
Ladder Intro Tutorial
PPTX
Introduction ot AutoCAD 2017
PPTX
Introduction to Arduino
 
PPTX
Electronz_Chapter_11.pptx
PPTX
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal

More Related Content

PPTX
Arduino
PPT
Arduino presentation by_warishusain
PDF
Arduino presentation
ODP
Introduction to Arduino
PPTX
Arduino
PPTX
Arduino
PPTX
Introduction to Arduino Hardware and Programming
PPSX
Aircraft Anti collision system using ZIGBEE Communication
Arduino
Arduino presentation by_warishusain
Arduino presentation
Introduction to Arduino
Arduino
Arduino
Introduction to Arduino Hardware and Programming
Aircraft Anti collision system using ZIGBEE Communication

What's hot

PDF
Programmable logic controller - Siemens S7-1200
PDF
Report on arduino
PPTX
Introduction to the Arduino
PDF
Arduino: Practicas con Arduino
PDF
Programación de autómatas PLC OMRON CJ/CP1
PDF
InTouch HMI SCADA
DOCX
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
PPTX
Lesson sample introduction to arduino
PDF
Introduction to AutoCAD
PPTX
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
PPTX
Simulación de Semáforo
PPT
PDF
Manual del sistema del controlador programable S7-200 SMART
PPTX
116. 03_INTRODUCTION OF SIMULIDE.pptx
PPTX
Introduction to Arduino
PDF
Auto Cad tutorial
PPT
Ladder Intro Tutorial
PPTX
Introduction ot AutoCAD 2017
PPTX
Introduction to Arduino
 
Programmable logic controller - Siemens S7-1200
Report on arduino
Introduction to the Arduino
Arduino: Practicas con Arduino
Programación de autómatas PLC OMRON CJ/CP1
InTouch HMI SCADA
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
Lesson sample introduction to arduino
Introduction to AutoCAD
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Simulación de Semáforo
Manual del sistema del controlador programable S7-200 SMART
116. 03_INTRODUCTION OF SIMULIDE.pptx
Introduction to Arduino
Auto Cad tutorial
Ladder Intro Tutorial
Introduction ot AutoCAD 2017
Introduction to Arduino
 

Similar to Arduino: Arduino lcd

PPTX
Electronz_Chapter_11.pptx
PPTX
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
PDF
Learn LCD Arduino-v1
DOCX
Lab Activity 3
PDF
Cassiopeia ltd Arduino follow-up workshop 2018
PPTX
Arduino Projects.pptx
PDF
publish manual
PDF
Arduino and Robotics
PDF
Hardware Hacking and Arduinos
PPTX
Sensors and Actuators in Arduino, Introduction
PPTX
Arduino slides
PPTX
Arduino Workshop Slides
PPT
Notes arduino workshop_15
PDF
Introduction to Arduino and Circuits
PDF
Arduino based applications part 2
PPTX
A Wireless Application of The Rain, Humidity and Temperature Sensors Based on...
PDF
International Journal of Engineering Research and Development
PPTX
Arduino Slides With Neopixels
PDF
Embedded system course projects - Arduino Course
PPTX
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Electronz_Chapter_11.pptx
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
Learn LCD Arduino-v1
Lab Activity 3
Cassiopeia ltd Arduino follow-up workshop 2018
Arduino Projects.pptx
publish manual
Arduino and Robotics
Hardware Hacking and Arduinos
Sensors and Actuators in Arduino, Introduction
Arduino slides
Arduino Workshop Slides
Notes arduino workshop_15
Introduction to Arduino and Circuits
Arduino based applications part 2
A Wireless Application of The Rain, Humidity and Temperature Sensors Based on...
International Journal of Engineering Research and Development
Arduino Slides With Neopixels
Embedded system course projects - Arduino Course
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9

More from SANTIAGO PABLO ALBERTO

PDF
Electroneumatica con circuitos secueciales con logica cableada
PDF
Arduino Blocks: Programacion visual con bloques para arduino 2 Edicion por Ju...
PDF
Principios de electrónica 7 Edicion por Albert Malvino y David J. Bates
PDF
Principios digitales por Roger L. Tokheim
PDF
Solicitud de empleo para el trabajo para
DOCX
secuencia electroneumática parte 1
DOCX
secuencia electroneumática parte 2
PDF
Manual de teoría y practica electroneumática avanzada
PDF
Programacion de PLC basado en Rslogix 500 por Roni Domínguez
PDF
Programación de microcontroladores PIC en C con Fabio Pereira
PDF
Análisis y Diseño de Sistemas de Control Digital por Ricardo Fernandez del Bu...
PDF
Arduino: Arduino de cero a experto
PDF
PDF
Quimica.pdf
PDF
Manual básico PLC OMRON
PDF
Catálogo de PLC S7-200 SMART
PDF
PLC: Automatismos industriales
PDF
PLC: Buses industriales y de campo practicas de laboratorio por Jose Miguel R...
PDF
PLC y Electroneumática: Electricidad y Automatismo eléctrico por Luis Miguel...
PDF
Electrónica: Diseño y desarrollo de circuitos impresos con Kicad por Miguel P...
Electroneumatica con circuitos secueciales con logica cableada
Arduino Blocks: Programacion visual con bloques para arduino 2 Edicion por Ju...
Principios de electrónica 7 Edicion por Albert Malvino y David J. Bates
Principios digitales por Roger L. Tokheim
Solicitud de empleo para el trabajo para
secuencia electroneumática parte 1
secuencia electroneumática parte 2
Manual de teoría y practica electroneumática avanzada
Programacion de PLC basado en Rslogix 500 por Roni Domínguez
Programación de microcontroladores PIC en C con Fabio Pereira
Análisis y Diseño de Sistemas de Control Digital por Ricardo Fernandez del Bu...
Arduino: Arduino de cero a experto
Quimica.pdf
Manual básico PLC OMRON
Catálogo de PLC S7-200 SMART
PLC: Automatismos industriales
PLC: Buses industriales y de campo practicas de laboratorio por Jose Miguel R...
PLC y Electroneumática: Electricidad y Automatismo eléctrico por Luis Miguel...
Electrónica: Diseño y desarrollo de circuitos impresos con Kicad por Miguel P...

Recently uploaded

PPTX
Role of In Vitro and In Vivo Testing biomedical engineering
PDF
AI-Driven CTI for Business: Emerging Threats, Attack Strategies, and Defensiv...
PDF
Hybrid Anomaly Detection Mechanism for IOT Networks
PPTX
Introduction Blockchains and Smart Contracts
PPTX
Optimizing Plant Maintenance — Key Elements of a Successful Maintenance Plan ...
PPTX
The Importance of Maintenance Budgets — Maximize Reliability & Control Costs ...
PPTX
MODULE 1-UNIT_1.pptx MODULE 1-UNIT_1.pptx MODULE 1-UNIT_1.pptx
PPTX
How to Create an Effective Monthly Preventive Maintenance Plan
PDF
IPEC Presentation - Partial discharge Pro .pdf
PDF
Structural Conservation Appraisal of Indian Monuments Preserving India’s Arch...
PPTX
ISO 14224 Compliance & CMMS Software — A Comprehensive Guide for Reliable Mai...
PPTX
Industrial Plant Safety – Comprehensive Guide for Workplace Safety & Risk Pre...
PDF
Best Architecture in Kovilpatti - Amar Dexign Scape.pdf
PPTX
How to Select the Right CMMS Software for Your Organization — A Complete Buye...
PPTX
علي نفط.pptx هندسة النفط هندسة النفط والغاز
PPTX
UnrealGameplayAbilitySystemPresentation.pptx
PPTX
Shutdown Maintenance Explained — Full Plant Turnaround & Best Practices with ...
PDF
BE-Python-Lab.pdf taught in msrit bangalore
PPTX
The Complete Guide to Energy Audits_ Unlocking Savings, Sustainability, and P...
PPTX
Preventive Maintenance Program for Compressors – Complete Guide
Role of In Vitro and In Vivo Testing biomedical engineering
AI-Driven CTI for Business: Emerging Threats, Attack Strategies, and Defensiv...
Hybrid Anomaly Detection Mechanism for IOT Networks
Introduction Blockchains and Smart Contracts
Optimizing Plant Maintenance — Key Elements of a Successful Maintenance Plan ...
The Importance of Maintenance Budgets — Maximize Reliability & Control Costs ...
MODULE 1-UNIT_1.pptx MODULE 1-UNIT_1.pptx MODULE 1-UNIT_1.pptx
How to Create an Effective Monthly Preventive Maintenance Plan
IPEC Presentation - Partial discharge Pro .pdf
Structural Conservation Appraisal of Indian Monuments Preserving India’s Arch...
ISO 14224 Compliance & CMMS Software — A Comprehensive Guide for Reliable Mai...
Industrial Plant Safety – Comprehensive Guide for Workplace Safety & Risk Pre...
Best Architecture in Kovilpatti - Amar Dexign Scape.pdf
How to Select the Right CMMS Software for Your Organization — A Complete Buye...
علي نفط.pptx هندسة النفط هندسة النفط والغاز
UnrealGameplayAbilitySystemPresentation.pptx
Shutdown Maintenance Explained — Full Plant Turnaround & Best Practices with ...
BE-Python-Lab.pdf taught in msrit bangalore
The Complete Guide to Energy Audits_ Unlocking Savings, Sustainability, and P...
Preventive Maintenance Program for Compressors – Complete Guide

Arduino: Arduino lcd

  • 1.
    Arduino: LCDDiagrams &CodeBrown County LibraryProject 01: Hello, World!Components needed: Arduino Uno board breadboard 16 jumper wires 16x2 LCD screen 10k potentiometer
  • 2.
    5/2018Brown County Library/*LCD01 : Hello World!Source: Code adapted from the Arduino.cc Hello World Tutorial(https://www.arduino.cc/en/Tutorial/HelloWorld)and Adafruit Arduino - Lesson 11. LCD Displays (https://learn.adafruit.com/adafruit-arduino-lesson-11-lcd-displays-1)*/#include <LiquidCrystal.h> // indicate that we want to use the Liquid Crystal library// initialize the library by associating any needed LCD interface pin// with the Arduino pin number that it is connected to// RS EN D4 D5 D6 D7LiquidCrystal lcd(7, 8, 9, 10, 11, 12);void setup() {lcd.begin(16, 2); // set up the LCD's number of columns and rowslcd.print("hello, world!"); // print a message to the LCD}void loop() {lcd.setCursor(0, 1); // set the cursor to column 0, row 1 (row 1 is the second row as counting begins with 0)lcd.print(millis() / 1000); // print the number of seconds since reset}
  • 3.
    5/2018Brown County LibraryProject02: Weather StationComponents needed: Arduino Uno board breadboard 19 jumper wires 16x2 LCD screen 10k potentiometer DHT11 temperature and humidity sensor
  • 4.
    5/2018Brown County Library/*LCD02 : Weather StationSource: Code adapted from the Arduino Project Handbook (Geddes, 2016) andladyada's DHT humidity/temperature sensors testing sketch (https://learn.adafruit.com/dht?view=all)*/#include <LiquidCrystal.h> // call the Liquid Crystal library#include <DHT.h> // call the DHT libraryconst int DHTPIN = 3; // pin connected to DHTconst int DHTTYPE = DHT11; // set the type of sensor// initialize the Liquid Crystal library by associating any needed LCD interface pin// with the Arduino pin number that it is connected to// RS E D4 D5 D6 D7LiquidCrystal lcd(7, 8, 9, 10, 11, 12);// initialize the DHT library by telling it the pin and sensor type// pin sensor typeDHT dht(DHTPIN, DHTTYPE);void setup() {dht.begin(); // start the DHT sensorlcd.begin(16, 2); // set up the LCD's number of columns and rows}void loop() {float h = dht.readHumidity(); // get a humidity readingfloat t = dht.readTemperature(); // get a temperature readingt = t * 9 / 5 + 32; // change temp reading from Celsius to Fahrenheitif (isnan(t) || isnan(h)) { // check that DHT sensor is workinglcd.setCursor(0, 0); // set the cursor to column 0, row 0lcd.print("Failed to read from DHT"); // if DHT is not working, display this} else { // otherwise show the readings on the screenlcd.clear();lcd.setCursor(0, 0); // set the cursor to column 0, row 0// display humidity readinglcd.print("Humidity: ");lcd.print(h);lcd.print("%");lcd.setCursor(0, 1); // set the cursor to column 0, row 1// display temperature readinglcd.print("Temp: ");lcd.print(t);lcd.print("f");}delay(1000); // stabilizes the LCD screen}
  • 5.
    5/2018Brown County LibraryIdeasto Build OnBuild an electronic Magic 8 Ball - ask a question and get an answer when you gently tap or shake yourbreadboard!See page 6 of this document.Try to beat a reaction timer - how quickly can you press a button when a RGB LED flashes red?See page 9 of this document.https://learn.sparkfun.com/tutorials/sik-experiment-guide-for-arduino---v33/experiment-12-driving-a-motorBuild your own time clock, complete with buttons to set the hour and minute!Note: The diagram for this project is a bit confusing – it make take some critical thinking to come up with yourown setup.https://www.hackster.io/Annlee_Fores/simple-arduino-digital-clock-without-rtc-7d4303Learn MoreWant to learn more about how LCD screens and Arduino Libraries work? Try these resources:Adafruit Arduino Lesson 11: LCD Displays Part 1. Simon Monk.https://learn.adafruit.com/adafruit-arduino-lesson-11-lcd-displays-1?view=allAdafruit Arduino Lesson 12: LCD Displays Part 2. Simon Monk.https://learn.adafruit.com/adafruit-arduino-lesson-12-lcd-displays-part-2?view=allAdafruit Tips, Tricks & Techniques: Arduino Libraries. Lady Ada and Tyler Cooper.https://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduino-librariesAdafruit Character LCDs OverView. Lady Ada and Tony DiCola.https://learn.adafruit.com/character-lcds?view=allArduino – Hello World! https://www.arduino.cc/en/Tutorial/HelloWorldArduino – Libraries. https://www.arduino.cc/en/Reference/LibrariesArduino Project Handbook. Mark Geddes. 2016. Pg. 102-132.Exploring Arduino: Tools and Techniques for Engineering Wizardry. Jeremy Blum. 2013. Pg. 199-219.Sparkfun SIK Experiment Guide for Arduino V4.0 – Circuit 4A: LCD “Hello World!”.https://learn.sparkfun.com/tutorials/sparkfun-inventors-kit-experiment-guide---v40/circuit-4a-lcd-hello-world
  • 6.
    5/2018Brown County LibraryExtraProject: Magic 8 BallComponents needed: Arduino Uno board breadboard 19 jumper wires 16x2 LCD screen 10k potentiometer 220 ohm resistor Tilt switch (four leg)
  • 7.
    5/2018Brown County Library/*LCDExtra Project : Magic 8 BallSource: Code adapted from the Arduino Projects Book (Fitzgerald, Shiloh & Igoe, 2012)and Arduino Project Handbook (Geddes, 2016)*/#include <LiquidCrystal.h>LiquidCrystal lcd(12, 11, 5, 4, 3, 2);const int switchPin = 6;int switchState = 0;int prevSwitchState = 0;int reply;void setup() {// put your setup code here, to run once:lcd.begin(16, 2);pinMode(switchPin,INPUT);lcd.print("Ask the");lcd.setCursor(0,1);lcd.print("Crystal Ball!");// if analog input pin 0 is unconnected, random analog// noise will cause the call to randomSeed() to generate// different seed numbers each time the sketch runs.// randomSeed() will then shuffle the random function.randomSeed(analogRead(0));}void loop() {// put your main code here, to run repeatedly:switchState = digitalRead(switchPin);if (switchState != prevSwitchState) {if (switchState == LOW) {reply = random(8);lcd.clear();lcd.setCursor(0, 0);lcd.print("The ball says:");lcd.setCursor(0, 1);switch(reply){case 0:lcd.print("Yes");break;case 1:
  • 8.
    5/2018Brown County Librarylcd.print("Mostlikely");break;case 2:lcd.print("Certainly");break;case 3:lcd.print("Outlook good");break;case 4:lcd.print("Unsure");break;case 5:lcd.print("Ask a Librarian");break;case 6:lcd.print("Doubtful");break;case 7:lcd.print("No");break;}}}prevSwitchState = switchState;}
  • 9.
    5/2018Brown County LibraryExtraProject: Reaction TimerComponents needed: Arduino Uno board breadboard 25 jumper wires 16x2 LCD screen 10k potentiometer 4 x 220 ohm resistors Piezo buzzer RGB LED (common cathode) Push button
  • 10.
    5/2018Brown County Library/*LCDExtra Project : Reaction TimerSource: Code adapted from the Arduino Project Handbook (Geddes, 2016)Originally created by Steven De Lannoyhttp://www.wingbike.nlUsed a RGB LED with a common anode (3 cathodes: R, G, B)*/#include <LiquidCrystal.h>LiquidCrystal lcd(12, 11, 5, 4, 3, 2);int LEDR = 8; // Pin connected to red LEDint LEDB = 6; // Pin connected to blue LEDint LEDGr = 7; // Pin connected to green LEDint Button = 9; // Pin connected to pushbuttonint COLOR; // Variable colorint Beep;int PSE; // Variable pauseint TME; // Timeint RTME = 0; // Reaction timevoid setup() {lcd.begin(16, 2);pinMode(LEDR, OUTPUT); // Set LED pins as outputpinMode(LEDB, OUTPUT);pinMode(LEDGr, OUTPUT);pinMode(Button, INPUT); // Set pushbutton as inputdigitalWrite(LEDR, LOW); // Switch on all LED colorsdigitalWrite(LEDB, LOW);digitalWrite(LEDGr, LOW);}void loop() {lcd.clear(); // Clear screenlcd.print("Hold Button to"); // Display message on LCD screenlcd.setCursor(0, 1); // Move to second linelcd.print("start.");while (digitalRead(Button) == LOW) { // Test does not start until// button is pushed (and held)tone(13, 1200, 30);delay(1400);noTone(13);}lcd.clear();digitalWrite(LEDR, HIGH); // Switch off start lightdigitalWrite(LEDB, HIGH);digitalWrite(LEDGr, HIGH);randomSeed(analogRead(0)); // Random noise from pin 0COLOR = random(1, 4); // Generate random colorPSE = random(500, 1200); // Set random pause duration between lights// Repeat this loop while color is green or blue AND pushbutton// is heldwhile (COLOR != 1 && digitalRead(Button) == HIGH) {digitalWrite(LEDGr, HIGH);digitalWrite(LEDB, HIGH);delay(PSE);randomSeed(analogRead(0));Beep = random(1, 4); // Select random beep from buzzer// (buzzer beeps 1 in 3 times)PSE = random(750, 1200); // Select random pause duration between// lights (to increase surprise effect)if (Beep == 1) {tone(13, 1600, 350);
  • 11.
    5/2018Brown County Librarydelay(750);noTone(13);}if(COLOR == 2) {digitalWrite(LEDGr, LOW);}if (COLOR == 3) {digitalWrite(LEDB, LOW);}delay(PSE);randomSeed(analogRead(0));COLOR = random(1, 4); // Select random color}// Execute this loop if color is redif (COLOR == 1 && digitalRead(Button) == HIGH) {digitalWrite(LEDGr, LOW);digitalWrite(LEDB, LOW);delay(50);TME = millis(); // Record time since program has starteddigitalWrite(LEDR, HIGH);while (digitalRead(Button) == HIGH) { // Runs until button is// released, recording the// reaction timedelay(1);}lcd.display();RTME = millis() - TME; // Reaction time in millisecondslcd.print("Reaction Time:"); // Display on LCD screenlcd.setCursor(0, 1);lcd.print(RTME);}// Execute if color is NOT red but the pushbutton is releasedif (COLOR != 1) {lcd.print("Released too");lcd.setCursor(0, 1); // Move to second linelcd.print("soon!!!");tone(13, 3000, 1500);delay(500);noTone(13);}// Test does not restart until the button is pushed oncewhile (digitalRead(Button) == LOW) {delay(10);}digitalWrite(LEDR, LOW); // Reset all lights to begin againdigitalWrite(LEDB, LOW);digitalWrite(LEDGr, LOW);lcd.clear();lcd.print("Hold Button to");lcd.setCursor(0, 1);lcd.print("start.");int Time = 0;delay(1000);}

[8]ページ先頭

©2009-2025 Movatter.jp