| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

LAB3_JorgeRamírez

Page history last edited by Benjamin Tee 9 years, 1 month ago

Jorge Ramírez López

5774573

 

Make a Digital Timer

 

a. How would you change the code to make the song play twice as fast?
Just multiply the note duration by a factor of two 

b. What song is playing? ;-) 

StarWars's song

Part B. Writing to the LCD
a. What voltage level do you need to power your display?
Supply Voltage(logic) from 4.5 to 5.5 volts 

b. What was one mistake you made when wiring up the display? How did you fix it?

I didn't wire the pin 1 and 2 of the LCD to the supply voltage and gnd. So i unplug the circuit in order to conect those pins. ✔ Good that you remembered to unplug the power. 

c. What line of code do you need to change to make it flash your name instead of "Hello World"?
The line that contains lcd.print("Jorge Ramirez :P"), that function is to print the string that is inside the parameters. 

Part C. Timer

a. Make a short video showing how your timer works, and what happens when time is up!

This is my code:

/*
  LiquidCrystal Library - Hello World
 
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 
 This sketch prints "Hello World!" to the LCD
 and shows the time.
 
  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 
 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// 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);
const int buttonPin = 7;
const int ledPin =  1;
int buttonState = 0;
int x=0;
void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Number of seconds ?");
   pinMode(ledPin, OUTPUT);
   pinMode(buttonPin, INPUT);
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  buttonState = digitalRead(buttonPin);
  if (buttonState == LOW) {
    x++;
    delay(500);
    lcd.setCursor(0, 1);
    lcd.print(x);
  }
  while(buttonState==HIGH && x!=0){
    lcd.setCursor(0, 1);
  // print the number of seconds since reset:
    lcd.print(x);
    for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    delay(30);                            
  }
    delay(970);
    x--;
  }
}

http://www.youtube.com/watch?v=Q1jK5QOyN1Y

 

Good job on the timer. It seemed that you had a slight issue with the timer showing '90' after '10' seconds. What happened there? How can you fix this problem? Nice use of blinking LED for visual feedback. 

b. Post a link to the Lab 3 Timers Hall of Fame.

Comments (0)

You don't have permission to comment on this page.