Class 04- Lab assignments 10 11 12

Lab assignment 10:
   H-Bridge integrated circuit. Reverse Motor
An H-bridge has up to 4 inputs and outputs with 2 separate power supplies. A potentiometer is used to control the power supply Arduino will send 2 seperate highs and lows change the motor direction.
Key terms:
// if the on/off button changed state since the last loop()
if (onOffSwitchState != previousOnOffSwitchState) {
// change the value of motorEnabled if pressed
if (onOffSwitchState == HIGH) {
motorEnabled = !motorEnabled

// if the motor is supposed to be on
if (motorEnabled == 1) {
// PWM the enable pin to vary the speed
analogWrite(enablePin, motorSpeed);
} else { // if the motor is not supposed to be on
//turn the motor off
analogWrite(enablePin, 0);


Lab assignment 11:   LCD Display with messages
Use a tilt switch randomly select 8 messages to be displayed on a lcd screen. Use the potentiometer to control the screen brightness. 
Key terms:
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// set up the number of columns and rows on the LCD
lcd.begin(16, 2);
// line 1 is the second row, since counting begins with 0
lcd.setCursor(0, 1);
// print to the second line
lcd.print(“Crystal Ball!”);



Lab assignment 12: Use a Piezo as a sound in input
Use a piezo as a sound input and monitor the sound values between different inputs to signal a LED output and control a servo motor which acts as a visual signal.
Key terms:
// import the library
#include <Servo.h>
// create an instance of the Servo library
Servo myServo;
// attach the servo to pin 9
// this function checks to see if a detected knock is within max and min range
boolean checkForKnock(int value) {
if (value > quietKnock && value < loudKnock) {
return true;
// check the value of the piezo
knockVal = analogRead(piezo);