This is follow on from the DS18b20 terminal example at http://www.pibits.net/learning/120.php , this time a python example Code [codesyntax lang=”python”] import os import glob import time os.system(‘modprobe w1-gpio’) #load one wire communication device kernel modules os.system(‘modprobe w1-therm’) base_dir = ‘/sys/bus/w1/devices/’ #point to the address device_folder = glob.glob(base_dir…
Code
-
-
In this example we will write some text on a PCD8554 LCD display, this is also commonly known as the Nokia 5100 LCD and is quite a common LCD which can be found in many Arduino projects. It frequently comes as an LCD which you…
-
In this example we use the database we created in the create database example and we will simply display all rows in the database [codesyntax lang=”python”] #!/usr/bin/python import sqlite3 as lite import sys con = lite.connect(‘test.db’) with con: cur = con.cursor() cur.execute(“SELECT * FROM Jobs”)…
-
In this example we create a SQLite database and insert some sample data into it, we will use this database in later examples [codesyntax lang=”python”] import sqlite3 as lite import sys con = lite.connect(‘test.db’) with con: cur = con.cursor() cur.execute(“CREATE TABLE Jobs(Id INT, Name TEXT,…
-
Another example using the pi4j library, this time displaying various clock speeds on your system [codesyntax lang=”java”] import com.pi4j.system.NetworkInfo; import com.pi4j.system.SystemInfo; import java.io.IOException; import java.text.ParseException; public class clockinfo { public static void main(String[] args) throws InterruptedException, IOException, ParseException { System.out.println(“—————————————————-“); System.out.println(“CLOCK INFO”); System.out.println(“—————————————————-“); System.out.println(“ARM Frequency…
-
This code example shows how to display some hardware information using the pi4l java library [codesyntax lang=”java”] import com.pi4j.system.NetworkInfo; import com.pi4j.system.SystemInfo; import java.io.IOException; import java.text.ParseException; public class hardwareinfo { public static void main(String[] args) throws InterruptedException, IOException, ParseException { System.out.println(“—————————————————-“); System.out.println(“HARDWARE INFO”); System.out.println(“—————————————————-“); System.out.println(“Serial Number…