Wednesday, 8 March 2017

Arduino - 7 Segment LED

Arduino Project #3


9 Second Seven Segment LTD Countdown Buzzer



This is a 7 segment LED connected to a 595N shift register.  When it counts down from 9 to 0 second, the buzzer will be activated.



Arduino circuit and sketch

//Pin connected to latch pin (ST_CP) of 74HC595
const int latchPin = 9;
//Pin connected to clock pin (SH_CP) of 74HC595
const int clockPin = 10;
////Pin connected to Data in (DS) of 74HC595
const int dataPin = 8;
const int buzz = 7;
const byte CHAR_COUNT = 10;

const byte symbols[CHAR_COUNT] = {
B01111110, // 0
B00010010, // 1
B10111100, // 2 
B10110110, // 3
B11010010, // 4 
B11100110, // 5
B11101110, // 6 
B00110010, // 7
B11111110, // 8 
B11110110  // 9
};

void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
  pinMode(buzz, OUTPUT);
  
}

void loop() {
  pattern1();

}

void pattern1()
{
  int i=9;
  while(i<CHAR_COUNT)
  {
    writeLeds(symbols[i]);
    if (i==0)
    tone(buzz,1000,1000);
    else 
    i = i-1; 
    delay(1000);
     
  }
}
void writeLeds(byte pattern)
{
  // turn off the output so the pins don't light up
  // while you're shifting bits:
  digitalWrite(latchPin, LOW);
  // turn on the next highest bit in bitsToSend:
  Serial.println(pattern,BIN);

  // shift the bits out:
  shiftOut(dataPin, clockPin, MSBFIRST, pattern);

    // turn on the output so the LEDs can light up:
  digitalWrite(latchPin, HIGH);
  }

Component Required:
seven segment LED, 595N Shift register, Buzzer, 220 Ohm resistor

Problem you may encounter:
If your 7 segment LED randomly lights up instead of showing numbers, you may try to change all the '1' into '0' and all '0' into '1' when you define 'symbols[CHAR_COUNT]'.




 





Monday, 30 January 2017

Arduino - 16x2 LCD Screen

Arduino Project #2


16x2 LCD Screen with I2C and Photoresistor

 
 

 This is a 16x2 LCD screen with I2C. You can read the value of the photoresistor from the LCD screen.

 
 
Arduino circuit and sketch



Things need to take note:
1. You need to download and install the "New LiquidCrystal" library (https://bitbucket.org/)
2. If you encounter the "<Wire.h> no such file or directory" error, you need to copy the Wire library under the same "library" folder as the LiquidCrystal_I2C library.

 


Monday, 2 January 2017

Arduino - Plant Lamp

Arduino Project - #1
Plant Lamp



This is a plant lamp I made using Arduino Uno. The lamp will automatically turn on when it is dark, so that the plant will be able to continue the process of photosynthesis. As and when there is sufficient light, the lamp will automatically switch off. 


                       Plant Lamp - Arduino circuit and sketch





* 'sensorValue' may be different due to different photo resistor 

                               
Plant Lamp - Step by Step
Things you need: a mineral water bottle, a few ice cream sticks, a led light and two wires, a piece of card board, aluminium foil, super glue. 

1. Drill a hole on the cap of mineral water; 
2. Glue the sticks together;
3. Cut the mineral bottle and glue the aluminium foil on the inside layer of mineral bottle;
4. Put the led light through the hole of the cap, connect the wires and glue the cap on the stick.
5. Cut a hole on the card board and glue the stick on the hole.  Now your lamp is ready to connect to Arduino !!!





Scratch Project - #4
Brick Breaker
Click Here To Play!