CS4101 Introduction to Embedded Systems Lab 10: Tasks and Scheduling

Slides:



Advertisements
Similar presentations
Chung-Ta King National Tsing Hua University
Advertisements

What is Arduino?  Arduino is a ATMEL 168 micro-controller kit designed specially for small projects  User friendly IDE(Integrated Development Environment)
Embedded Programming and Robotics Lesson 9 Keypad and LCD Display 1.
Autumn, 2013C.-S. Shieh, EC, KUAS, Taiwan1 智慧電子應用設計導論 (1/3) Display Chin-Shiuh Shieh ( 謝欽旭 ) Department of Electronic Engineering.
Parallax 4x20 LCD (part number 27979) with Arduino Duemilanove
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Digital Outputs LCD Display
Practical Electronics & Programming
Franz Duran INTRODUCTION TO A RDUINO PROGRAMMING & INTERFACING Engr. Franz Duran, MEP-ECE RapidSignal Electronics.
ARDUINO 1. Basics  Comments  /* * Blink * * The basic Arduino example. Turns on an LED on for one second, * then off for one second, and so on... We.
Microcontrollers, Microcomputers, and Microprocessors
ECE 447 Fall 2009 Lecture 12: TI MSP430 External LCD.
AAPT workshop W03 July 26, 2014 Saint Cloud State University, MN, USA
Arduino + Bluetooth TYWu. Connection Arduino + Bluetooth Module.
Arduino Programming Part 6: LCD Panel Output ME 121 Portland State University.
Infrared Proximity Sensors & Liquid Crystal Display Instructor Dr Matthew Khin Yi Kyaw.
CEng3361 CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2011 Recitation 06.
Introduction In this lab , we will learn
Using a SparkFun™ serial LCD with an Arduino
Making a 24hr Timer.
Lab 7 Basic 1: Game of Memory
Introduction In this lab , we will learn
Outline Introduction to digital-to-analog converter (DAC)
CS4101 嵌入式系統概論 General Purpose IO
Lab 2: Arduino Sensors Topics: Arduino Sensor Reading, Display
Outline Analog to digital conversion (ADC) of NuMaker TRIO
Peripherals – Keypad The Keypad provides a simple means of numerical data or control input. The keys can be attributed whatever data or control values.
LCD Interfacing using Atmega 32
More on LED’s with Arduino
Val Manes Department of Math & Computer Science
Manual for Arduino Kit v1.0
CS4101 Introduction to Embedded Systems Lab 11: Task Synchronization
CS4101 Introduction to Embedded Systems Lab 6: Low-Power Optimization
Microcontroller basics
LCD and Keyboard Interfacing
CS4101 Introduction to Embedded Systems Lab 12: Task Synchronization
UNIVERSAL COLLEGE OF ENGINEERING & TECHNOLOGY
CS4101 Introduction to Embedded Systems Lab 1: General Purpose IO
GANDHINAGAR INSTITUTE OF TECHNOLOGY
LCD.
Prof. Chung-Ta King Department of Computer Science
COMP211 Computer Logic Design Introduction to the DE2 Board
DIGITAL CALCULATOR USING 8051
CS4101 Introduction to Embedded Systems Lab 9: NuMaker ADC and LCD
CS4101 嵌入式系統概論 General Purpose IO
Arduino Part 1 Topics: Microcontrollers Programming Basics
INC 161 , CPE 100 Computer Programming
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 2: Timer and Clock Prof. Chung-Ta King Department of Computer Science National.
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 3: Interrupt Prof. Chung-Ta King Department of Computer Science National Tsing.
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 6: Serial Communication Prof. Chung-Ta King Department of Computer Science National.
EET 2261 Unit 11 Controlling LCD and Keypad
Schedule 8:00-11:00 Workshop: Arduino Fundamentals
Subject Name: Microprocessors Subject Code:10EC46 Department: Electronics and Communication Date: /10/2018.
LCD and Keyboard Interfacing
EET 2261 Unit 11 Controlling LCD and Keypad
LCD and Keyboard Interfacing
CS4101 Introduction to Embedded Systems Lab 8: Arduino DAC and PWM
Data Representation Conversion 05/12/2018.
LCD and Keyboard Interfacing
LCD and Keyboard Sepehr Naimi
Sensors and actuators Sensors Resistive sensors
LCD and Keyboard Interfacing
CTY SAR FCPS Shawn Lupoli, Elliot Tan
CTY SAR FCPS Shawn Lupoli, Elliot Tan
LCD (LIQUID CRISTAL DISPLAY) SCREENS
CS4101 Introduction to Embedded Systems Lab 2: Basic IO and Timer
Prof. Chung-Ta King Department of Computer Science
CTY SAR FCPS Vedant mathur, Juliana schalkwyk
LCD.
2019 Investing Now Summer Program
Presentation transcript:

CS4101 Introduction to Embedded Systems Lab 10: Tasks and Scheduling Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan

Introduction In this lab, we will learn… More sensors Buzzer, LCD display, hex keypad How to do task scheduling on Arduino?

Buzzer Piezoelectric buzzer: Contains a metal disc that deforms under a current By applying an alternating current at a high enough frequency, the disc will move fast to create a sound wave You have two buzzers; use left one Side view Bottom view

Playing a Tone tone(pin, frequency) tone(pin, frequency, duration) Generates a square wave of the specified frequency (and 50% duty cycle) on a pin A duration can be specified, otherwise the wave continues until a call to noTone() Only one tone can be generated at a time. If the tone is playing on the same pin, the call will set its frequency. For Uno: min frequency 31 Hz; max frequency 65535 Hz

Sample Code for Buzzer int buzzer = 10; int i = 0; void setup() { pinMode(buzzer, OUTPUT); } void loop() { for(i=0; i<10; i++) { // imitate sound of ambulance if(i%2 == 0) tone(buzzer,698); else tone(buzzer, 523); delay(500); noTone(buzzer); // turn off the buzzer delay(2000);

LCD Display Liquid crystal displays (LCDs) are commonly used to display data in devices such as calculators and many other electronic devices. They may support message scrolling, cursor displaying, and LED backlight Most commonly used LCD display is 16×2 LCD Module, which can display 32 ASCII characters in 2 lines (16 characters in 1 line) LCM1602 IIC V1

1620 IIC LCD GND (ground) VCC (power supply 5V) SDA (i2c data line) SCL (i2c clock)

LCD Library Please download the library to support 1602 IIC LCD from this website: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads Please download the newest version Remove the original LiquidCrystal folder under arduino- 1.6.12\libraries

LCD Library Unzip the file under arduino-1.6.12\libraries

Sample Code for LCD #include <Wire.h> #include <LiquidCrystal_I2C.h> // Set the pins on the I2C chip used for LCD connections: // addr, en,rw,rs,d4,d5,d6,d7,bl,blpol LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); void setup() { lcd.begin(16, 2); // initialize LCD lcd.backlight(); // open LCD backlight lcd.setCursor(0, 0); // setting cursor lcd.print("Hello, world!"); delay(1000); lcd.clear(); lcd.setCursor(0, 1); lcd.print("Type to display"); } void loop() { } rs: the number of the Arduino pin that is connected to the RS pin on the LCD rw: the number of the Arduino pin that is connected to the RW pin on the LCD (optional) enable: the number of the Arduino pin that is connected to the enable pin on the LCD d0, d1, d2, d3, d4, d5, d6, d7: the numbers of the Arduino pins that are connected to the corresponding data pins on the LCD. d0, d1, d2, and d3 are optional; if omitted, the LCD will be controlled using only the four data lines (d4, d5, d6, d7).

Hex Keypad Use “column scanning” to identify the pressed key  In this method a particular row is kept low and other rows are held high. Then the logic status of each column line is scanned. If a particular column is found low, then that means the key that comes in between that column and row is short (pressed). Then the program registers that key being pressed. Then the same procedure is applied for the subsequent rows and the entire process is repeated. Use “column scanning” to identify the pressed key http://www.circuitstoday.com/interfacing-hex-keypad-to-arduino

Hex Keypad Library Please download the library from this website: http://playground.arduino.cc/uploads/Code/keypad.zip Unzip the file under arduino-1.6.12\libraries

Sample Code for Hex Keypad #include <Keypad.h>      #define KEY_ROWS 4 #define KEY_COLS 4   char keymap[KEY_ROWS][KEY_COLS] = {   {'1', '2', '3', 'A'},   {'4', '5', '6', 'B'},   {'7', '8', '9', 'C'},   {'*', '0', '#', 'D'} }; // Column pin 1~4 byte colPins[KEY_COLS] = {9, 8, 7, 6}; byte rowPins[KEY_ROWS] = {13, 12, 11, 10};

Sample Code for Hex Keypad  // initialize keypad Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, KEY_ROWS, KEY_COLS);   void setup(){   Serial.begin(9600); } void loop(){   char key = myKeypad.getKey();      if (key)       Serial.println(key);

Lab 10 Basic 1: Implement a traffic light The traffic light will set the green LED on for 4 sec, then the yellow LED on for 2 sec, and the red LED on for 6 sec, and repeat. The traffic light will change to the green light when there is an ambulance passing, which is represented by a buzzer The buzzer will be turned on for 4 sec at 2 Hz (0.5 sec on and 0.5 sec off), indicating that the ambulance will need 4 sec to pass the cross road The starting time is set randomly between 7 and 12 sec. During the 4 sec that the buzzer sounds, the traffic light will be turned to the green LED. After the 4 sec, the traffic light returns to normal.

Lab 10 Basic 1 (cont.) Set the priority of the tasks properly. Show the current state and duration of the state on the LCD. For example: if the green light is on for three seconds, then show the string “green light” and the number “3” on the LCD.

Lab 10 Basic 2: Implement a simple Screensaver Silent mode: The backlight is off. If the input from the hex keypad is ‘*’, then go to the unlock mode. Unlock mode: Turn on the backlight and print “Enter password:” If the user enters the correct password (at least 3 characters), then go back to the silent mode. Otherwise, stay in the unlock mode.