LCD + BH1750 Bar Graph

IMG_1419

This sketch requires LcdBarGraph and BH1750 library.

You can download the library here

https://docs.google.com/file/d/0B4qM0hq-OmC1RHhEcXRNSmZ1YW8/

#include <LiquidCrystal.h>
#include <LcdBarGraph.h>
#include <Wire.h>
#include <BH1750.h>

BH1750 lightMeter;

byte lcdNumCols = 16; // — number of columns in the LCD
byte sensorPin = 2; // — value for this example

LiquidCrystal lcd(8,9,10,11,12,13); // — creating LCD instance
LcdBarGraph lbg(&lcd, lcdNumCols);// — creating a 4 char wide baraph in the end of second column (column 1)

void setup(){
// — initializing the LCD
lcd.begin(2, lcdNumCols);
lcd.clear();
lightMeter.begin();
// — do some delay: some time I’ve got broken visualization
delay(100);

}

void loop()
{
uint16_t lux = lightMeter.readLightLevel();
// — draw bar graph from the analog value readed
lbg.drawValue((lux), 30);
// — do some delay: frequent draw may cause broken visualization
delay(100);
}

Advertisements
Posted in Arduino Project | Leave a comment

16×2 LCD

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8,9,10,11,12,13);
void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16,2);
// Print a message to the LCD.
lcd.print(”   cmosgr”);
lcd.setCursor(0,1);
lcd.print(”  wordpress.com”);
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
}

Posted in Arduino Project | Leave a comment

Relay Board + Temperature Sensor (DS18B20) + LCD (with serial printing)

IMG_1366

This sketch requires OneWire  library.

You can download the library here

https://docs.google.com/file/d/0B4qM0hq-OmC1RHhEcXRNSmZ1YW8/

 

#define RELAY1  3 // Relay on digital pin 3
#include <OneWire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,10,11,12,13);
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2

//Temperature chip i/o
OneWire ds(DS18S20_Pin);  // on digital pin 2

void setup(void) {
pinMode(RELAY1, OUTPUT);
Serial.begin(9600);
lcd.begin(16,2);
float temperature = getTemp();
lcd.print(“TEMP   – STATUS”);
}

void loop(void) {
pinMode(RELAY1, OUTPUT);
float temperature = getTemp();
Serial.println(temperature);
lcd.setCursor(0,1);
lcd.print(temperature);
delay(2000); //just here to slow down the output so it is easier to read
if (temperature >32) {
digitalWrite(3,LOW);lcd.print(” RELAY ON “);
} else {
digitalWrite(3,HIGH);lcd.print(” RELAY OFF”);
}
}

float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius

byte data[12];
byte addr[8];

if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}

if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println(“CRC is not valid!”);
return -1000;
}

if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print(“Device is not recognized”);
return -1000;
}

ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end

byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad

for (int i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
}

ds.reset_search();

byte MSB = data[1];
byte LSB = data[0];

float tempRead = ((MSB << 8) | LSB); //using two’s compliment
float TemperatureSum = tempRead / 16;

return TemperatureSum;

}

Posted in Arduino Project | Leave a comment

Relay Board + Temperature Sensor (DS18B20) (with serial printing)

This sketch requires OneWire library.

You can download the library here

https://docs.google.com/file/d/0B4qM0hq-OmC1RHhEcXRNSmZ1YW8/

#define RELAY1  2 //(Digital Pin 2)
#include <OneWire.h>

int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2

//Temperature chip i/o
OneWire ds(DS18S20_Pin);  // on digital pin 2

void setup(void) {
pinMode(RELAY1, OUTPUT);
Serial.begin(9600);
}

void loop(void) {
pinMode(RELAY1, OUTPUT);
float temperature = getTemp();
Serial.println(temperature);
delay(2000); //just here to slow down the output so it is easier to read
if (temperature >32) {
digitalWrite(2,LOW);
} else {
digitalWrite(2,HIGH);
}
}

float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius

byte data[12];
byte addr[8];

if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}

if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println(“CRC is not valid!”);
return -1000;
}

if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print(“Device is not recognized”);
return -1000;
}

ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end

byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad

for (int i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
}

ds.reset_search();

byte MSB = data[1];
byte LSB = data[0];

float tempRead = ((MSB << 8) | LSB); //using two’s compliment
float TemperatureSum = tempRead / 16;

return TemperatureSum;

}

Posted in Arduino Project | Leave a comment

8 Relay Board (HL-58S V1.0)

IMG_1331

#define RELAY1  2   //(Digital Pin 2)

#define RELAY2  3

#define RELAY3  4

#define RELAY4  5

#define RELAY5  6

#define RELAY6  7

#define RELAY7  8

#define RELAY8  9  //(Digital Pin 9)

void setup()

{

// Initialise the Arduino data pins for OUTPUT

pinMode(RELAY1, OUTPUT);

pinMode(RELAY2, OUTPUT);

pinMode(RELAY3, OUTPUT);

pinMode(RELAY4, OUTPUT);

pinMode(RELAY5, OUTPUT);

pinMode(RELAY6, OUTPUT);

pinMode(RELAY7, OUTPUT);

pinMode(RELAY8, OUTPUT);

}

void loop()

{

digitalWrite(RELAY1,LOW);           // Turns ON Relays 1

delay(1000);                                      // Wait 1 seconds

digitalWrite(RELAY1,HIGH);          // Turns Relay Off

digitalWrite(RELAY2,LOW);           // Turns ON Relays 2

delay(1000);                                      // Wait 1 seconds

digitalWrite(RELAY2,HIGH);          // Turns Relay Off

digitalWrite(RELAY3,LOW);           // Turns ON Relays 3

delay(1000);                                      // Wait 1 seconds

digitalWrite(RELAY3,HIGH);          // Turns Relay Off

digitalWrite(RELAY4,LOW);           // Turns ON Relays 4

delay(1000);                                      // Wait 1 seconds

digitalWrite(RELAY4,HIGH);          // Turns Relay Off

digitalWrite(RELAY5,LOW);           // Turns ON Relays 5

delay(1000);                                      // Wait 1 seconds

digitalWrite(RELAY5,HIGH);          // Turns Relay Off

digitalWrite(RELAY6,LOW);           // Turns ON Relays 6

delay(1000);                                      // Wait 1 seconds

digitalWrite(RELAY6,HIGH);          // Turns Relay Off

digitalWrite(RELAY7,LOW);           // Turns ON Relays 7

delay(1000);                                      // Wait 1 seconds

digitalWrite(RELAY7,HIGH);          // Turns Relay Off

digitalWrite(RELAY8,LOW);           // Turns ON Relays 8

delay(1000);                                      // Wait 1 seconds

digitalWrite(RELAY8,HIGH);          // Turns Relay Off
}

Posted in Arduino Project | Leave a comment

Arduino Mega 2560

Arduino Mega 2560

 

ArduinoADK_R3_Front

The Arduino Mega 2560 is a microcontroller board based on the ATmega2560 (datasheet). It has 54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. The Mega is compatible with most shields designed for the Arduino Duemilanove or Diecimila.

The Mega 2560 is an update to the Arduino Mega, which it replaces.

The Mega2560 differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the ATmega16U2 (ATmega8U2 in the revision 1 and revision 2 boards) programmed as a USB-to-serial converter.
Revision 2 of the Mega2560 board has a resistor pulling the 8U2 HWB line to ground, making it easier to put into DFU mode.
Revision 3 of the board has the following new features:

  • 1.0 pinout: added SDA and SCL pins that are near to the AREF pin and two other new pins placed near to the RESET pin, the IOREF that allow the shields to adapt to the voltage provided from the board. In future, shields will be compatible both with the board that use the AVR, which operate with 5V and with the Arduino Due that operate with 3.3V. The second one is a not connected pin, that is reserved for future purposes.
  • Stronger RESET circuit.
  • Atmega 16U2 replace the 8U2.

Ream more

http://arduino.cc/en/Main/arduinoBoardMega2560

Posted in Arduino Microcontrollers | Tagged | Leave a comment