Saturday 31 March 2012

Week 10

After done with stand alone arduino circuit, i start to construct the reed switch sensor to Atmega 328 with LCD display. 


Part list
1. Stand alone arduino circuit from last week (Atmega 328)
2.2x16 LCD  ( refer week 8)
3. reed switch
4. resistor 10 kohm




First step, i sketch the schematic diagram by using fritzing software like figure below:


Full schematic diagram using fritzing
Second step, i construct the connection on the breadboard like figure below:




Full connection on Breadboard





Then, i  upload the programmed by Arduino board to Atmega328P-PU :



/*
  
  The circuit:
 * LCD RS pin to digital pin 7
 * LCD Enable pin to digital pin 8
 * LCD D4 pin to digital pin 9
 * LCD D5 pin to digital pin 10
 * LCD D6 pin to digital pin 11
 * LCD D7 pin to digital pin 12
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)




 */


// include the library code:
#include <LiquidCrystal.h>


// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);


int ledPin = 13;               // choose pin for the LED




void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
   pinMode(2,INPUT);
   pinMode(ledPin, OUTPUT);      // declare LED as output
 // Print a message to the LCD.
  lcd.print("    Welcome   ");
  lcd.setCursor(0, 1);
  lcd.print("  Mc-Ergocycle  ");  
}






void loop() {
   
   if ( digitalRead(2)== HIGH)             // == digunakan bagi declare condition
   {  digitalWrite(ledPin, HIGH);  // turn LED OFF
  } else {
    digitalWrite(ledPin, LOW); // turn LED ON
  } 
  
   }
   
  

After uploading the programmed, i has testing the circuit and get the result as show in figure below : 






Video for the testing :










No comments:

Post a Comment