Using switch/case as the core of your state machine

Size: px
Start display at page:

Download "Using switch/case as the core of your state machine"

Transcription

1 state code examples #2 1/8 Using switch/case as the core of your state machine a state machine with an on/off switch and a button that changes the LED color each time you press the button. our states. We could do these with #defines once we've learned them "static" means this variable's value cannot be changed once it's set, it's a good way to prevent yourself from accidentally changing the value in your code. These *must* be declared "const int" and not just "int", don't ask why, just do it or your code will not compile. const int soff = 0; const int sred = 1; const int sblue = 2; const int sgreen = 3; the current state we're in at any given time. We want to start in "off", so we set the variable to soff when we declare it. int we need to have somewhere to go when we leave soff, so let's pick red int our on/off switch int onoffpin = 2; the momentary switch we use to change the color int colorpin = 4; the LEDs int redled = 10; int greenled = 11; int blueled = 9; int statusled = 13; void setup() pinmode(onoffpin, INPUT); pinmode(colorpin, INPUT); pinmode(statusled, OUTPUT); pinmode(redled, OUTPUT); pinmode(blueled, OUTPUT); pinmode(greenled, OUTPUT); if we didn't set the initial state when we created the variable, we'd do it here. The initial state is "off" or "start" in most state machines, but if you only have active/on states, pick an appropriate starting state.

2 state code examples #2 2/8 Serial.begin(9600); void loop() BlinkStatusLed(); Every time through the loop we check the state we're in with a switch/case statement. switch/case statements are replacement for using lots of if/else statements. Instead of doing this: if (a == 1) then /* statements*/ else if (a == 2) then /* statements*/ else if (a == 3) then /* statements*/ we can use switch/case and do this: switch(a) start of the switch statement case 1: /* statements */ case 2: /* statements */ case 3: /* statements */ default: /* statements */ the end of the switch statement. You *have* to have a "" at the end of each "case". When the Arduino gets to a "break" statement, it exits the switch statement the "default" case is what the switch statement should do if nothing is matched. In the above example, if a is 1, 2, or 3 we do something. But if a was 4, it wouldn't match the first three cases and the "default" case is used. For our state machines, we should not have a default case that does anything other than generate an error message and reset the state machine for our state machine, each state is contained in its own case statement. in each case, the first thing we do is check to see if we should be in a different state. If not, then we go ahead and do whatever we need to do in this state. switch(currentstate) this is the start of the switch case soff: this starts the state of "soff" and this is what we do if currentstate == soff

3 state code examples #2 3/8 Serial.println("off"); if (digitalread(onoffpin) == HIGH) currentstate = nextstate; this ends the state of "soff" case sred: start of the "red" case Serial.println("red"); if (digitalread(onoffpin) == LOW) else if (digitalread(colorpin) == HIGH) currentstate = sblue; else PulseLed(redLed); end of the red case. case sblue: Serial.println("blue"); if (digitalread(onoffpin) == LOW) else if (digitalread(colorpin) == HIGH) currentstate = sgreen; else PulseLed(blueLed); case sgreen: Serial.println("green"); if (digitalread(onoffpin) == LOW) else if (digitalread(colorpin) == HIGH) currentstate = sred; else PulseLed(greenLed); default: the default case, which is an error for us Serial.println("ERROR: default state"); this is the end of the case, where we go after we hit a

4 state code examples #2 4/8 void PulseLed(int pin) for (int i=0; i<=255; i++) analogwrite(pin, i); for (int i=255; i>=0; i--) analogwrite(pin, i); void BlinkStatusLed() digitalwrite(statusled,high); delay(100); digitalwrite(statusled,low); ; delay(100);

5 state code examples #2 5/8 Reading a Switch While Pulsing an LED a state machine with an on/off switch and a button that changes the LED color each time you press the button. as was demonstrated in class with state_machine_switch.pde, there's a bug: if some pushes the "change" button while the PulseLed() subroutine is happening, the button is ignored. PulseLed() is busy making the LED get brighter and darker and does not actually read the button. one solution is to read the button while you're in PulseLed(). But if you read the button, how do you get that information back to your state machine so it can do the right thing? We will solve this by changing PulseLed so that it reads the button while pulsing, then returns a value of "true" if the button was pushed. Compare this program with state_machine_switch.pde and look at the differences in what we do. We're still implementing the same state machine as before, but we read the button more often and have a better interaction experience with the button pusher. Also, see the case for sred for some comments on how we change reading the button in our state machine now that we can read the button while pulsing the LED. const int soff = 0; const int sred = 1; const int sblue = 2; const int sgreen = 3; the current state we're in at any given time. We want to start in "off", so we set the variable to soff when we declare it. int we need to have somewhere to go when we leave soff, so let's pick red int our on/off switch int onoffpin = 2; the momentary switch we use to change the color int colorpin = 4; the LEDs int redled = 10; int greenled = 11; int blueled = 9; int statusled = 13; void setup()

6 state code examples #2 6/8 pinmode(onoffpin, INPUT); pinmode(colorpin, INPUT); pinmode(statusled, OUTPUT); pinmode(redled, OUTPUT); pinmode(blueled, OUTPUT); pinmode(greenled, OUTPUT); if we didn't set the initial state when we created the variable, we'd do it here. The initial state is "off" or "start" in most state machines, but if you only have active/on states, pick an appropriate starting state. Serial.begin(9600); void loop() BlinkStatusLed(); switch(currentstate) case soff: Serial.println("off"); if (digitalread(onoffpin) == HIGH) currentstate = nextstate; case sred: Serial.println("red"); if (digitalread(onoffpin) == LOW) now that we can read the colorpin while we're pulsing the LED, we no longer need to explicitly read it here. We just pulse the LED, and if the button was pushed while we were reading, we change the state. else if (PulseLedReadButton(redLed, colorpin) == true) currentstate = sblue; case sblue: Serial.println("blue"); if (digitalread(onoffpin) == LOW) else if (PulseLedReadButton(blueLed, colorpin) == true) currentstate = sgreen;

7 state code examples #2 7/8 case sgreen: Serial.println("green"); if (digitalread(onoffpin) == LOW) else if (PulseLedReadButton(greenLed, colorpin) == true) currentstate = sred; default: the default case, which is an error for us Serial.println("ERROR: default state"); we've made two major changes to PulseLed (which is still here so you can compare them) 1) our new function returns a value. Just like digitalread() returns a value of HIGH or LOW, our new function can return "true" or "false". We use a "boolean" variable for this, can only be "true" or "false". Anything that calls PulseLedReadButton has to do something with this value. (If you want to pulse an led but not check the button, call PulseLed() instead.) 2) When you call PulseLedReadButton, you have to tell it what pin the button is on. boolean PulseLedReadButton(int lpin, int bpin) we need to keep track of whether or not a button was pushed. The default is that it was not pushed. boolean buttonpushed = false; now, every time through each loop, we read the pin to see if the button is being pushed. If it is, save that information. we also do something a bit clever to make the program more efficient. If the button *has* been pushed, there's no need to read it again for (int i=0; i<=255; i++) analogwrite(lpin, i); if (buttonpushed == false) if ( digitalread(bpin) == HIGH) buttonpushed = true;

8 state code examples #2 8/8 for (int i=255; i>=0; i--) analogwrite(lpin, i); if (buttonpushed == false) if ( digitalread(bpin) == HIGH) buttonpushed = true; the "return" statement is how we get the information back to the code that called us. return buttonpushed; the previous version of PulseLed void PulseLed(int pin) for (int i=0; i<=255; i++) analogwrite(pin, i); for (int i=255; i>=0; i--) analogwrite(pin, i); void BlinkStatusLed() digitalwrite(statusled,high); delay(100); digitalwrite(statusled,low); ; delay(100);

Arduino Lesson 16. Stepper Motors

Arduino Lesson 16. Stepper Motors Arduino Lesson 16. Stepper Motors Created by Simon Monk Last updated on 2013-11-22 07:45:14 AM EST Guide Contents Guide Contents Overview Parts Part Qty Breadboard Layout Arduino Code Stepper Motors Other

More information

Theory and Practice of Tangible User Interfaces. Thursday Week 2: Digital Input and Output. week. Digital Input and Output. RGB LEDs fade with PWM

Theory and Practice of Tangible User Interfaces. Thursday Week 2: Digital Input and Output. week. Digital Input and Output. RGB LEDs fade with PWM week 02 Digital Input and Output RGB LEDs fade with PWM 1 Microcontrollers Output Transducers actuators (e.g., motors, buzzers) Arduino Input Transducers sensors (e.g., switches, levers, sliders, etc.)

More information

Arduino Internet Connectivity: Maintenance Manual Julian Ryan Draft No. 7 April 24, 2015

Arduino Internet Connectivity: Maintenance Manual Julian Ryan Draft No. 7 April 24, 2015 Arduino Internet Connectivity: Maintenance Manual Julian Ryan Draft No. 7 April 24, 2015 CEN 4935 Senior Software Engineering Project Instructor: Dr. Janusz Zalewski Software Engineering Program Florida

More information

Lecture 2 Notes: Flow of Control

Lecture 2 Notes: Flow of Control 6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The

More information

TUTORIAL FOR INITIALIZING BLUETOOTH COMMUNICATION BETWEEN ANDROID AND ARDUINO

TUTORIAL FOR INITIALIZING BLUETOOTH COMMUNICATION BETWEEN ANDROID AND ARDUINO TUTORIAL FOR INITIALIZING BLUETOOTH COMMUNICATION BETWEEN ANDROID AND ARDUINO some pre requirements by :-Lohit Jain *First of all download arduino software from www.arduino.cc *download software serial

More information

C4DI Arduino tutorial 4 Things beginning with the letter i

C4DI Arduino tutorial 4 Things beginning with the letter i C4DI Arduino tutorial 4 Things beginning with the letter i If you haven t completed the first three tutorials, it might be wise to do that before attempting this one. This tutorial assumes you are using

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall 2012. Work in teams of two!

Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall 2012. Work in teams of two! Using Your Arduino, Breadboard and Multimeter Work in teams of two! EAS 199A Fall 2012 pincer clips good for working with breadboard wiring (push these onto probes) Your Multimeter probes leads Turn knob

More information

Using Arduino Microcontrollers to Sense DC Motor Speed and Position

Using Arduino Microcontrollers to Sense DC Motor Speed and Position ECE480 Design Team 3 Using Arduino Microcontrollers to Sense DC Motor Speed and Position Tom Manner April 4, 2011 page 1 of 7 Table of Contents 1. Introduction ----------------------------------------------------------

More information

Backing up with Windows 7

Backing up with Windows 7 Backing up your data should be a high priority; it is far too easy for computer failure to result in the loss of data. All hard drives will eventually fail, and (at the minimum) you should be prepared

More information

Connecting Arduino to Processing a

Connecting Arduino to Processing a Connecting Arduino to Processing a learn.sparkfun.com tutorial Available online at: http://sfe.io/t69 Contents Introduction From Arduino......to Processing From Processing......to Arduino Shaking Hands

More information

Arduino project. Arduino board. Serial transmission

Arduino project. Arduino board. Serial transmission Arduino project Arduino is an open-source physical computing platform based on a simple microcontroller board, and a development environment for writing software for the board. Open source means that the

More information

6. Control Structures

6. Control Structures - 35 - Control Structures: 6. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose,

More information

Arduino Lesson 5. The Serial Monitor

Arduino Lesson 5. The Serial Monitor Arduino Lesson 5. The Serial Monitor Created by Simon Monk Last updated on 2013-06-22 08:00:27 PM EDT Guide Contents Guide Contents Overview The Serial Monitor Arduino Code Other Things to Do 2 3 4 7 10

More information

cs281: Introduction to Computer Systems Lab08 Interrupt Handling and Stepper Motor Controller

cs281: Introduction to Computer Systems Lab08 Interrupt Handling and Stepper Motor Controller cs281: Introduction to Computer Systems Lab08 Interrupt Handling and Stepper Motor Controller Overview The objective of this lab is to introduce ourselves to the Arduino interrupt capabilities and to use

More information

CONTROL SWITCHER User s Manual (Preliminary)

CONTROL SWITCHER User s Manual (Preliminary) CONTROL SWITCHER User s Manual (Preliminary) www.voodoolab.com Copyright 2010 by Digital Music Corporation. This publication is protected by copyright and all rights are reserved. Voodoo Lab, Control Switcher,

More information

Version Control with. Ben Morgan

Version Control with. Ben Morgan Version Control with Ben Morgan Developer Workflow Log what we did: Add foo support Edit Sources Add Files Compile and Test Logbook ======= 1. Initial version Logbook ======= 1. Initial version 2. Remove

More information

Help on the Embedded Software Block

Help on the Embedded Software Block Help on the Embedded Software Block Powersim Inc. 1. Introduction The Embedded Software Block is a block that allows users to model embedded devices such as microcontrollers, DSP, or other devices. It

More information

Programming the VEX Robot

Programming the VEX Robot Preparing for Programming Setup Before we can begin programming, we have to set up the computer we are using and the robot/controller. We should already have: Windows (XP or later) system with easy-c installed

More information

A PRACTICAL GUIDE TO db CALCULATIONS

A PRACTICAL GUIDE TO db CALCULATIONS A PRACTICAL GUIDE TO db CALCULATIONS This is a practical guide to doing db (decibel) calculations, covering most common audio situations. You see db numbers all the time in audio. You may understand that

More information

Keil C51 Cross Compiler

Keil C51 Cross Compiler Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation

More information

Table of Contents. Part I Introduction 2. Part II Keyboard Monitor 2. Part III Console Viewer 4. Part IV FAQ 5. Part V Support 6. Index 0.

Table of Contents. Part I Introduction 2. Part II Keyboard Monitor 2. Part III Console Viewer 4. Part IV FAQ 5. Part V Support 6. Index 0. Contents I Table of Contents Part I Introduction 2 1 Setup... 2 Part II Keyboard Monitor 2 Part III Console Viewer 4 1 Options... 4 Part IV FAQ 5 Part V Support 6 Index 0 I 2 CYBERsitter Keyboard Monitor

More information

This loop prints out the numbers from 1 through 10 on separate lines. How does it work? Output: 1 2 3 4 5 6 7 8 9 10

This loop prints out the numbers from 1 through 10 on separate lines. How does it work? Output: 1 2 3 4 5 6 7 8 9 10 Java Loops & Methods The while loop Syntax: while ( condition is true ) { do these statements Just as it says, the statements execute while the condition is true. Once the condition becomes false, execution

More information

Boolean Logic in MATLAB

Boolean Logic in MATLAB Boolean Logic in MATLAB When programming, there will be times when you want to control the flow of your code based on certain events occurring or certain values being reached. Primarily, this is handled

More information

Working with forms in PHP

Working with forms in PHP 2002-6-29 Synopsis In this tutorial, you will learn how to use forms with PHP. Page 1 Forms and PHP One of the most popular ways to make a web site interactive is the use of forms. With forms you can have

More information

Debouncing Switches. Mechanical switches are one of the most common interfaces to a uc.

Debouncing Switches. Mechanical switches are one of the most common interfaces to a uc. Mechanical switches are one of the most common interfaces to a uc. Switch inputs are asynchronous to the uc and are not electrically clean. Asynchronous inputs can be handled with a synchronizer (2 FF's).

More information

1 /*ora sincrinizzata con NTP. Inserendo codice OTP si attiva un servo che ruota di 95 grad. Per chiudere il servo premere 2 "*" mentre per azzerrare

1 /*ora sincrinizzata con NTP. Inserendo codice OTP si attiva un servo che ruota di 95 grad. Per chiudere il servo premere 2 * mentre per azzerrare 1 /*ora sincrinizzata con NTP. Inserendo codice OTP si attiva un servo che ruota di 95 grad. Per chiudere il servo premere 2 "*" mentre per azzerrare il codice premenre "#" 3 */ 4 #include 5 #include

More information

Arduino Lesson 14. Servo Motors

Arduino Lesson 14. Servo Motors Arduino Lesson 14. Servo Motors Created by Simon Monk Last updated on 2013-06-11 08:16:06 PM EDT Guide Contents Guide Contents Overview Parts Part Qty The Breadboard Layout for 'Sweep' If the Servo Misbehaves

More information

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

Introduction to Arduino

Introduction to Arduino Introduction to Arduino // Basic Arduino reference sheet: Installation: Arduino: http://www.arduino.cc/en/guide/homepage Fritzing: http://fritzing.org/download/ Support: Arduino: http://www.arduino.cc,

More information

LAB #4 Sequential Logic, Latches, Flip-Flops, Shift Registers, and Counters

LAB #4 Sequential Logic, Latches, Flip-Flops, Shift Registers, and Counters LAB #4 Sequential Logic, Latches, Flip-Flops, Shift Registers, and Counters LAB OBJECTIVES 1. Introduction to latches and the D type flip-flop 2. Use of actual flip-flops to help you understand sequential

More information

Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board

Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board Abstract This application note is a tutorial of how to use an Arduino UNO microcontroller to

More information

Example of a Java program

Example of a Java program Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);

More information

IR Communication a learn.sparkfun.com tutorial

IR Communication a learn.sparkfun.com tutorial IR Communication a learn.sparkfun.com tutorial Available online at: http://sfe.io/t33 Contents Getting Started IR Communication Basics Hardware Setup Receiving IR Example Transmitting IR Example Resources

More information

Arduino Lesson 1. Blink

Arduino Lesson 1. Blink Arduino Lesson 1. Blink Created by Simon Monk Last updated on 2015-01-15 09:45:38 PM EST Guide Contents Guide Contents Overview Parts Part Qty The 'L' LED Loading the 'Blink' Example Saving a Copy of 'Blink'

More information

MIDECO 64-outputs MIDI note decoder USER MANUAL. Roman Sowa 2012

MIDECO 64-outputs MIDI note decoder USER MANUAL. Roman Sowa 2012 MIDECO 64-outputs MIDI note decoder USER MANUAL Roman Sowa 2012 www.midi-hardware.com 1.Overview Thank you for choosing MIDECO as your new MIDI-to-digital converter. This short manual will guide you through

More information

Arduino Lesson 13. DC Motors. Created by Simon Monk

Arduino Lesson 13. DC Motors. Created by Simon Monk Arduino Lesson 13. DC Motors Created by Simon Monk Guide Contents Guide Contents Overview Parts Part Qty Breadboard Layout Arduino Code Transistors Other Things to Do 2 3 4 4 4 6 7 9 11 Adafruit Industries

More information

Lego Robot Tutorials Touch Sensors

Lego Robot Tutorials Touch Sensors Lego Robot Tutorials Touch Sensors Bumper Cars with a Touch Sensor With a touch sensor and some robot programming, you can make your robot search its way around the room. It can back up and turn around

More information

1. Use the class definition above to circle and identify the parts of code from the list given in parts a j.

1. Use the class definition above to circle and identify the parts of code from the list given in parts a j. public class Foo { private Bar _bar; public Foo() { _bar = new Bar(); public void foobar() { _bar.moveforward(25); 1. Use the class definition above to circle and identify the parts of code from the list

More information

Arduino Lesson 4. Eight LEDs and a Shift Register

Arduino Lesson 4. Eight LEDs and a Shift Register Arduino Lesson 4. Eight LEDs and a Shift Register Created by Simon Monk Last updated on 2014-09-01 11:30:10 AM EDT Guide Contents Guide Contents Overview Parts Part Qty Breadboard Layout The 74HC595 Shift

More information

Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go

Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go Debugging ESE112 Java Programming: API, Psuedo-Code, Scope It is highly unlikely that you will write code that will work on the first go Bugs or errors Syntax Fixable if you learn to read compiler error

More information

Testing your Linux Virtual Box

Testing your Linux Virtual Box Testing your Linux Virtual Box This document will guide you through downloading and installing the software you need for this offering. Make sure you get a fully working system early in the week so you

More information

Working with microcontroller-generated audio frequencies (adapted from the Machine Science tutorial)

Working with microcontroller-generated audio frequencies (adapted from the Machine Science tutorial) Working with microcontroller-generated audio frequencies (adapted from the Machine Science tutorial) If we attach a speaker between a microcontroller output pin and ground, we can click the speaker in

More information

Event counters in NOVA

Event counters in NOVA Case study: how to use the event counters in NOVA? 1 Event counter support NOVA Technical Note 22 Event counters in NOVA Most of the measurement commands, like CV staircase or Record signals (> 1 ms) provide

More information

Mobile MessageBank Standard User Guide

Mobile MessageBank Standard User Guide 1. Now Everyone Gets The Message 2. MessageBank Stard Set Up 3. Using MessageBank 4. Options 5. Pricing 6. Billing 7. Troubleshooting 8. Helpful Hints 9. Tips 10. More Information Mobile MessageBank Stard

More information

Sending an SMS with Temboo

Sending an SMS with Temboo Sending an SMS with Temboo Created by Vaughn Shinall Last updated on 2015-01-21 01:15:14 PM EST Guide Contents Guide Contents Overview Get Set Up Generate Your Sketch Upload and Run Push to Send Wiring

More information

Basic Router and Switch Instructions (Cisco Devices)

Basic Router and Switch Instructions (Cisco Devices) Basic Router and Switch Instructions (Cisco Devices) Basic Device Connection 1. Connect to the device via the console cable (light blue cable) and the use of a terminal program (Windows Hyperterminal,

More information

Aura Kitchen Monitor. 2012 Coherent Software Solutions

Aura Kitchen Monitor. 2012 Coherent Software Solutions Part Introduction I 1 Introduction Introduction Kitchen Items is an alternative method for alerting kitchen staff about new orders waiting to be prepared. When compared to the standard method of passing

More information

Interrupts and the Timer Overflow Interrupts Huang Sections 6.1-6.4. What Happens When You Reset the HCS12?

Interrupts and the Timer Overflow Interrupts Huang Sections 6.1-6.4. What Happens When You Reset the HCS12? Interrupts and the Timer Overflow Interrupts Huang Sections 6.1-6.4 o Using the Timer Overflow Flag to interrupt a delay o Introduction to Interrupts o How to generate an interrupt when the timer overflows

More information

EARTH PEOPLE TECHNOLOGY SERIAL GRAPH TOOL FOR THE ARDUINO UNO USER MANUAL

EARTH PEOPLE TECHNOLOGY SERIAL GRAPH TOOL FOR THE ARDUINO UNO USER MANUAL EARTH PEOPLE TECHNOLOGY SERIAL GRAPH TOOL FOR THE ARDUINO UNO USER MANUAL The Serial Graph Tool for the Arduino Uno provides a simple interface for graphing data to the PC from the Uno. It can graph up

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

How To Control A Car With A Thermostat

How To Control A Car With A Thermostat :» : :.:35152, 2013 2 5 1: 6 1.1 6 1.2 7 1.3 7 1.4 7 1.5 8 1.6 8 1.7 10 1.8 11 1.9 11 2: 14 2.1 14 2.2 14 2.2.1 14 2.2.2 16 2.2.3 19 2.2.4 20 2.2.5 21 2.2.6 Reed Relay 23 2.2.7 LCD 2x16 5VDC 23 2.2.8 RGB

More information

BLOCK OCCUPANCY DETECTOR WITH SEMAPHORE OPERATION BOD1/DAP4-BR

BLOCK OCCUPANCY DETECTOR WITH SEMAPHORE OPERATION BOD1/DAP4-BR BLOCK OCCUPANCY DETECTOR WITH SEMAPHORE OPERATION BOD1/DAP4-BR This Block Occupancy Detector recognises the current drawn by moving trains within a block, and can operate a number of built-in programs

More information

Lab 6 Introduction to Serial and Wireless Communication

Lab 6 Introduction to Serial and Wireless Communication University of Pennsylvania Department of Electrical and Systems Engineering ESE 111 Intro to Elec/Comp/Sys Engineering Lab 6 Introduction to Serial and Wireless Communication Introduction: Up to this point,

More information

Auto Clicker Tutorial

Auto Clicker Tutorial Auto Clicker Tutorial This Document Outlines Various Features of the Auto Clicker. The Screenshot of the Software is displayed as below and other Screenshots displayed in this Software Tutorial can help

More information

Calling the Function. Two Function Declarations Here is a function declared as pass by value. Why use Pass By Reference?

Calling the Function. Two Function Declarations Here is a function declared as pass by value. Why use Pass By Reference? Functions in C++ Let s take a look at an example declaration: Lecture 2 long factorial(int n) Functions The declaration above has the following meaning: The return type is long That means the function

More information

SnagIt Add-Ins User Guide

SnagIt Add-Ins User Guide Version 8.1 User Guide By TechSmith Corp. User Guide User Guide Contents User s Guide 1 Overview...1 Word, PowerPoint, and Excel Add-Ins...2 Outlook Add-In...2 Internet Explorer / Windows Explorer Add-In...2

More information

How To Program An Nxt Mindstorms On A Computer Or Tablet Computer

How To Program An Nxt Mindstorms On A Computer Or Tablet Computer NXT Generation Robotics Introductory Worksheets School of Computing University of Kent Copyright c 2010 University of Kent NXT Generation Robotics These worksheets are intended to provide an introduction

More information

Translating C code to MIPS

Translating C code to MIPS Translating C code to MIPS why do it C is relatively simple, close to the machine C can act as pseudocode for assembler program gives some insight into what compiler needs to do what's under the hood do

More information

CSC230 Getting Starting in C. Tyler Bletsch

CSC230 Getting Starting in C. Tyler Bletsch CSC230 Getting Starting in C Tyler Bletsch What is C? The language of UNIX Procedural language (no classes) Low-level access to memory Easy to map to machine language Not much run-time stuff needed Surprisingly

More information

Using your Bluetooth laptop with the Logitech wireless hub

Using your Bluetooth laptop with the Logitech wireless hub Using your Bluetooth laptop with the Logitech wireless hub 2003 Logitech, Inc. Contents Introduction 3 Product compatibility 3 About this guide 4 Get connected 5 Connecting your Bluetooth laptop 5 Checking

More information

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following: In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our

More information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program. Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

More information

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority) Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the

More information

CS412 Interactive Lab Creating a Simple Web Form

CS412 Interactive Lab Creating a Simple Web Form CS412 Interactive Lab Creating a Simple Web Form Introduction In this laboratory, we will create a simple web form using HTML. You have seen several examples of HTML pages and forms as you have worked

More information

C Programming Structure of a C18 Program

C Programming Structure of a C18 Program What does this document covers? This document attempts to explain the basic structure of a C18 program. It is followed by some simple examples. A very simple C18 program is shown below: Example 1 What

More information

My EA Builder 1.1 User Guide

My EA Builder 1.1 User Guide My EA Builder 1.1 User Guide COPYRIGHT 2014. MyEABuilder.com. MetaTrader is a trademark of MetaQuotes www.metaquotes.net. Table of Contents MAIN FEATURES... 3 PC REQUIREMENTS... 3 INSTALLATION... 4 METATRADER

More information

Getting Started with WebSite Tonight

Getting Started with WebSite Tonight Getting Started with WebSite Tonight WebSite Tonight Getting Started Guide Version 3.0 (12.2010) Copyright 2010. All rights reserved. Distribution of this work or derivative of this work is prohibited

More information

An Introduction To Simple Scheduling (Primarily targeted at Arduino Platform)

An Introduction To Simple Scheduling (Primarily targeted at Arduino Platform) An Introduction To Simple Scheduling (Primarily targeted at Arduino Platform) I'm late I'm late For a very important date. No time to say "Hello, Goodbye". I'm late, I'm late, I'm late. (White Rabbit in

More information

Arduino Shield Manual

Arduino Shield Manual Arduino Shield Manual Version 1.4 www.dfrobot.com Copyright 2010 by DFRobot.com Table of Contents Arduino I/O Expansion Shield... 4 Introduction... 4 Diagram... 4 Sample Code... 4 Arduino Motor Shield...

More information

Red Hat Linux 7.2 Installation Guide

Red Hat Linux 7.2 Installation Guide Red Hat Linux 7.2 Installation Guide Ryan Spangler spanglerrp22@uww.edu http://ceut.uww.edu April 2002 Department of Business Education/ Computer and Network Administration Copyright Ryan Spangler 2002

More information

Microcontroller Code Example Explanation and Words of Wisdom For Senior Design

Microcontroller Code Example Explanation and Words of Wisdom For Senior Design Microcontroller Code Example Explanation and Words of Wisdom For Senior Design For use with the following equipment: PIC16F877 QikStart Development Board ICD2 Debugger MPLAB Environment examplemain.c and

More information

Two-way selection. Branching and Looping

Two-way selection. Branching and Looping Control Structures: are those statements that decide the order in which individual statements or instructions of a program are executed or evaluated. Control Structures are broadly classified into: 1.

More information

An Introduction to MPLAB Integrated Development Environment

An Introduction to MPLAB Integrated Development Environment An Introduction to MPLAB Integrated Development Environment 2004 Microchip Technology Incorporated An introduction to MPLAB Integrated Development Environment Slide 1 This seminar is an introduction to

More information

Conditions & Boolean Expressions

Conditions & Boolean Expressions Conditions & Boolean Expressions 1 In C++, in order to ask a question, a program makes an assertion which is evaluated to either true (nonzero) or false (zero) by the computer at run time. Example: In

More information

The first program: Little Crab

The first program: Little Crab CHAPTER 2 The first program: Little Crab topics: concepts: writing code: movement, turning, reacting to the screen edges source code, method call, parameter, sequence, if-statement In the previous chapter,

More information

Java Interview Questions and Answers

Java Interview Questions and Answers 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java

More information

Lecture 7: Programming for the Arduino

Lecture 7: Programming for the Arduino Lecture 7: Programming for the Arduino - The hardware - The programming environment - Binary world, from Assembler to C - - Programming C for the Arduino: more - Programming style Lect7-Page1 The hardware

More information

Tuesday, October 18. Configuration Management (Version Control)

Tuesday, October 18. Configuration Management (Version Control) Tuesday, October 18 Configuration Management (Version Control) How Version Control Works Place the official version of source code into a central repository, or database Programmers check out a working

More information

Lesson 8: Simon - Arrays

Lesson 8: Simon - Arrays Lesson 8: Simon - Arrays Introduction: As Arduino is written in a basic C programming language, it is very picky about punctuation, so the best way to learn more complex is to pick apart existing ones.

More information

Simple Cooperative Scheduler for Arduino ARM & AVR. Aka «SCoop»

Simple Cooperative Scheduler for Arduino ARM & AVR. Aka «SCoop» Simple Cooperative Scheduler for Arduino ARM & AVR Aka «SCoop» Introduction Yet another library This library aims to provide a light and simple environment for creating powerful multi-threaded programs

More information

Destiny 4100. Destiny 4100. Owners Manual

Destiny 4100. Destiny 4100. Owners Manual Destiny 4100 Destiny 4100 Owners Manual TABLE OF CONTENTS INTRODUCTION Control Panel...3 Detection Devices...3 Telephone Keypads...3 GLOSSARY... 4-5 LOCAL PHONE ACCESS Using Your Telephones As Keypads...6

More information

Introduction to Arduino

Introduction to Arduino Introduction to Arduino With ArduBlock & LilyPad Dev Brian Huang Education Engineer brian.huang@sparkfun.com Pre-Class Survey http://bit.ly/14xk3ek Resources This PPT ArduBlock Download & Installation

More information

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description

More information

PloneSurvey User Guide (draft 3)

PloneSurvey User Guide (draft 3) - 1 - PloneSurvey User Guide (draft 3) This short document will hopefully contain enough information to allow people to begin creating simple surveys using the new Plone online survey tool. Caveat PloneSurvey

More information

Lazy OpenCV installation and use with Visual Studio

Lazy OpenCV installation and use with Visual Studio Lazy OpenCV installation and use with Visual Studio Overview This tutorial will walk you through: How to install OpenCV on Windows, both: The pre-built version (useful if you won t be modifying the OpenCV

More information

OVERVIEW HARDWARE. Mode buttons. USB Micro socket. Kensington Security Slot. 8x8 playable grid. Mode buttons

OVERVIEW HARDWARE. Mode buttons. USB Micro socket. Kensington Security Slot. 8x8 playable grid. Mode buttons OVERVIEW Launchpad Mini is a compact version of the celebrated Novation Launchpad for the ipad generation. 64 three-colour pads enable you to produce and perform music with your ipad by triggering samples

More information

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void 1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of

More information

Mathematical Induction

Mathematical Induction Mathematical Induction In logic, we often want to prove that every member of an infinite set has some feature. E.g., we would like to show: N 1 : is a number 1 : has the feature Φ ( x)(n 1 x! 1 x) How

More information

2 The first program: Little Crab

2 The first program: Little Crab 2 The first program: Little Crab topics: concepts: writing code: movement, turning, reacting to the screen edges source code, method call, parameter, sequence, if statement In the previous chapter, we

More information

File: C:\Program Files\Robotics Academy\RobotC\sample programs\rcx\arushi\robot_

File: C:\Program Files\Robotics Academy\RobotC\sample programs\rcx\arushi\robot_ ///////////////////////////////////////////////////////////////////////// // // This is the Program to control the Robot Head // Program By: Arushi Raghuvanshi // Date: Oct 2006 // /////////////////////////////////////////////////////////////////////////

More information

Fusion Voicemail Plus User Guide For Android Devices

Fusion Voicemail Plus User Guide For Android Devices Welcome to Fusion Voicemail Plus! Fusion Voicemail Plus User Guide For Android Devices Fusion Voicemail Plus (FVM+) is a replacement for the ordinary voicemail that you use with your cellular phone company.

More information

Intermediate STEMSEL Project 6 Light Sensor Alarm

Intermediate STEMSEL Project 6 Light Sensor Alarm Intermediate STEMSEL Project 6 Light Sensor Alarm Problem What items are important for survival in an emergency situation? How can we secure our goods? We want to create an alarm that can work even in

More information

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders 1.00 Lecture 1 Course Overview Introduction to Java Reading for next time: Big Java: 1.1-1.7 Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

More information

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python Introduction Welcome to our Python sessions. University of Hull Department of Computer Science Wrestling with Python Week 01 Playing with Python Vsn. 1.0 Rob Miles 2013 Please follow the instructions carefully.

More information

Software based Finite State Machine (FSM) with general purpose processors

Software based Finite State Machine (FSM) with general purpose processors Software based Finite State Machine (FSM) with general purpose processors White paper Joseph Yiu January 2013 Overview Finite state machines (FSM) are commonly used in electronic designs. FSM can be used

More information

System update procedure for Kurio 7 (For build number above 110)

System update procedure for Kurio 7 (For build number above 110) System update procedure for Kurio 7 (For build number above 110) IMPORTANT NOTE: Before starting the procedure, please check your current Android build number, that can be found as follows: exit the Kurio

More information

Basic Pulse Width Modulation

Basic Pulse Width Modulation EAS 199 Fall 211 Basic Pulse Width Modulation Gerald Recktenwald v: September 16, 211 gerry@me.pdx.edu 1 Basic PWM Properties Pulse Width Modulation or PWM is a technique for supplying electrical power

More information

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine Blender Notes Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine The Blender Game Engine This week we will have an introduction to the Game Engine build

More information

CHAPTER 11: Flip Flops

CHAPTER 11: Flip Flops CHAPTER 11: Flip Flops In this chapter, you will be building the part of the circuit that controls the command sequencing. The required circuit must operate the counter and the memory chip. When the teach

More information