Wiring and coding a beautiful screen RC1602B5-LLH-JWV with Arduino

I came across this great looking screen on TME one day and decided to give it a go. Unfortunately, I didn’t manage to get it to work on the first attempt.

I found it recently in my things and decided to give it a go. I finally managed to display things on it, and it is beautiful!

Here’s a list of things I used:

Wire your screen as I showed on image below made with Fritzing.

Please keep in mind that I had to use parts that were available in Fritzing.

Here is what it looks like in my case:

Once you got your screen connected, its the time for coding!

// HelloWorld - simple demonstration of lcd
// Created by Bill Perry 2016-07-02
// bperrybap@opensource.billsworld.billandterrie.com
//
// This example code is unlicensed and is released into the public domain
// ----------------------------------------------------------------------------
// 
// Sketch will print "Hello, World!" on top row of lcd
// and will print the amount of time since the Arduino has been reset
// on the second row.
//
// If initialization of the LCD fails and the arduino supports a built in LED,
// the sketch will simply blink the built in LED.
//

#include <Wire.h>	// can be left out in arduino.cc IDE 1.6.7 and later
#include <hd44780.h>	// can be left out in arduino.cc IDE 1.6.7 and later
#include <hd44780_I2Clcd.h>

//
// enter address of LCD.
// Addresses seen so far include:
// - 0x3a, 0x3b (PCF2119x)
// - 0x3c (unknwon chip)
// - 0x3d (unknwon chip)
// - 0x3e (unknwon chip)
// - 0x3f (unknwon chip)

const int i2c_addr = 0x3c;

hd44780_I2Clcd lcd(i2c_addr);

// LCD geometry
const int LCD_ROWS = 2;
const int LCD_COLS = 16;

void setup()
{
	// initialize LCD with number of columns and rows: 
	if( lcd.begin(LCD_COLS, LCD_ROWS))
	{
		// begin() failed so blink the onboard LED if possible
#ifdef LED_BUILTIN
		pinMode(LED_BUILTIN, OUTPUT);
		while(1)
		{
			digitalWrite(LED_BUILTIN, HIGH);
			delay(500);
			digitalWrite(LED_BUILTIN, LOW);
			delay(500);
		}
#else
		while(1){} // spin and do nothing
#endif
	}
	
	// Print a message to the LCD
	lcd.print("Hello, World!");
}

void loop()
{
static unsigned long lastsecs = -1; // pre-initialize with non zero value
unsigned long secs;

	secs = millis() / 1000;

	// see if 1 second has passed
	// so the display is only updated once per second
	if(secs != lastsecs)
	{
		lastsecs = secs; // keep track of last seconds

		// set the cursor position to column 0, row 1
		// note: row 1 is the second row from top,
		// since row counting begins with 0
		lcd.setCursor(0, 1);

		// print uptime on lcd device: (time since last reset)
		PrintUpTime(lcd, secs);
	}
}

// PrintUpTime(outdev, secs) - print uptime in HH:MM:SS format
// outdev - the device to send output
//   secs - the total number of seconds uptime
void PrintUpTime(Print &outdev, unsigned long secs)
{
unsigned int hr, mins, sec;

	// convert total seconds to hours, mins, seconds
	mins =  secs / 60;	// how many total minutes
	hr = mins / 60;		// how many total hours
	mins = mins % 60;	// how many minutes within the hour
	sec = secs % 60;	// how many seconds within the minute
		

	// print uptime in HH:MM:SS format
	// Print class does not support fixed width formatting
	// so insert a zero if number smaller than 10
	if(hr < 10)
		outdev.write('0');
	outdev.print((int)hr);
	outdev.write(':');
	if(mins < 10)
		outdev.write('0');
	outdev.print((int)mins);
	outdev.write(':');
	if(sec < 10)
		outdev.write('0');
	outdev.print((int)sec);
}

[Python / OSX]Get network connection details, restart wifi, and do more than you think straight from python

Hi!
I recently figured out how to restart internet(en0) interface on OSX and read some interesting details about our connection. Thanks to objc library I was able to access objective-C methods provided by OSX.
Here is CWInterface Class Reference. Check it out because this documentation provide many interesting methods.

Continue reading [Python / OSX]Get network connection details, restart wifi, and do more than you think straight from python