Showing posts with label learning. Show all posts
Showing posts with label learning. Show all posts

Tuesday, March 11, 2014

Arduino 4x20 LCD and 2 inputs comparator

Staring a new build. So as to that I had an idea, that it can be helpful for everyone starting with code writing to try and manipulate this snippet. It's a simple code to operate a LCD and 2 inputs on A0 and A1. It compares the two with if and else. After the comparator it makes a readable output on the LCD. From here it's very simple to put the comparison into outputs of your own choosing.




//4x20 LCD, 2 sensors in A0 and A1 compare them and output to the LCD
// include the library code:
#include <LiquidCrystal.h>

// initialize the library liquidcrystal.h with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int sensorPin1 = A0; // defines input pin
int sensorValue1 = 0; // make a varianle sensorValue
int sensorPin2 = A1;
int sensorValue2 = 0;

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(20, 4);

}

void loop() {

  sensorValue1 = analogRead(sensorPin1); // get the value of sensor 1
  sensorValue2 = analogRead(sensorPin2); // get valur for sensor 2

    lcd.setCursor(0, 0); // Set cursor to top left
  lcd.print(sensorValue1);

  lcd.setCursor(0, 1);
  lcd.print(sensorValue2);

  if (sensorValue1 < sensorValue2){
    lcd.setCursor(0, 2);
    lcd.print("1 is higher than 2");
  }
  else{
    lcd.setCursor(0, 3);
    lcd.print("2 is higher than 1");
  }

  delay(200);
  lcd.clear();


}

Sunday, February 2, 2014

Max7219 and a LED matrix with Arduino, blinking LED-s the hard way

DIY led matrix
DIY 7805 PSU
 First trial to make the 7219 work with Arduino. I had ordered the MAX7219-s a good few months ago, but still hadn't made anything with them. So this is mi stab at making them work. In mi junk bin i had a bunch of perf board and white led-s so just a matter of soldering together I thought. Well soldering is the easy part but to mi surprise it took a good hour or so to solder the 7805 coupled with 7219 and the led matrix together.

So mi first attempt. To replicate or try it for yourself you need.

  • Soldering iron
  • 30 LED-s
  • MAX7219 IC
  • 7805 Voltage regulator
  • 10 uF and 100 uF capacitors
  • jumper wires

Max7219 connected with DIY 5x6 Led matrix