---

Showing posts sorted by relevance for query breadboard. Sort by date Show all posts
Showing posts sorted by relevance for query breadboard. Sort by date Show all posts

Saturday, April 1, 2017

Introducing the MonkMakesDuino

Yet another Arduino clone, but his time a bit different in that is is designed with education and breadboard use as its main goal.

Its on KICKSTARTER now, so take a look if you are interested.
The main features are:
  • Breadboard friendly - clearly labelled pins
  • Arduino Uno compatible (Board Type: Arduino Uno in the Arduino IDE)
  • Low-cost simple design
  • Built in USB interface with high quality drivers available (CP2102)
  • Polyfuse over-current protection
  • 5V USB powered
  • Buffered 'L' LED on pin 13
You get the same pins as the Arduino Uno (more or less) but in a single line that fits over one edge of the breadboard, leaving the rest of the breadboard free for your project.




Thursday, July 26, 2012

Raspberry Pi GPIO driving Servo

I have experimented with GPIO on the Raspberry Pi, just turning an LED on and off here. But since then Ben Croston has improved the RPi GPIO Python library to do most of the work in C and I can confirm that it is a lot faster. Driving servo motors requires precise timing, so I decided to see how the Pi would perform this task.

Here is a video of the servo in action. It is set to stay on the left for a few seconds, then move to the middle position, then swing all the way to the right, then scoot back to the left.



As you can see it works, but is rather jittery. This would make it okay for some applications.

Here is what I did, for anyone wishing to try it for themselves.

Schematic


I did not like the idea of using the GPIO pin to directly drive the control signal for the servo. You may get away with it, but I wouldn't risk it, and it may not work as the GPIO pins are 3V where as the servo expects a 5V control signal.

The transistor I used was a BC548, but any similar NPN transistor (like the 2N2222) should do the trick.

Breadboard

To build this prototype, I used Adafruit's Cobbler. This very handy little gadget allows you to link the GPIO connector to breadboard.

Here is the breadboard layout:
You might want to open this up to full size to see what's going on.

The transistor is in the bottom three rows. The bottom most row being connected to GND on the cobbler, the base connection (second row up) is linked by a 1kΩ resistor to #17 on the cobbler.

An external 5V power supply was used to provide the power to the servo. I tried using the 5V connection from the servo, but even with big (2200µF) and small capacitors across the supply, the load from the servo was enough to crash the Pi. This external power supply was connected to the red and green jumper leads to the left.

A second 1kΩ resistor is connected from the external +5V to the collector of the transistor (third row up) using another 1kΩ resistor.

The connections to the servo are GND, +5V (from the external supply) and the control signal from the collector of the transistor (yellow lead).

Software

You will need to install the new version of the RPi.GPIO library from here. I used version 0.3.1a.

It requires you install python3-dev by entering the following from the terminal:

sudo apt-get install python3-dev

To install the library itself, fetch the archive from the link above, unpack into a directory and then run the command:

sudo python3 setup.py install

If you need more instructions on this, see my earlier post here. This part of the installation is the same, except I am now using python3 instead of python.

Here is the Python program to generate the pulses.


import RPi.GPIO as GPIO
import time

pin = 17
refresh_period = 0.02

GPIO.setmode(GPIO.BCM)

GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, True)

while True:
    for i in range(1, 100):
        GPIO.output(pin, False)
        time.sleep(0.001)
        GPIO.output(pin, True)
        time.sleep(refresh_period)

    for i in range(1, 100):
        GPIO.output(pin, False)
        time.sleep(0.0015)
        GPIO.output(pin, True)
        time.sleep(refresh_period)

    for i in range(1, 100):
        GPIO.output(pin, False)
        time.sleep(0.002)
        GPIO.output(pin, True)
        time.sleep(refresh_period)

This has to be run as root, so save it in a file called 'servo_test.py' and then run it with the command:

sudo python3 servo_test.py

The program generates pulses for the servo that look like this:


The pulses need to be about 20 mS apart, and the length of each pulse determines the servo position. A pulse of 1.5mS puts it in the middle position, 1.0mS one side and 2.0mS the other side.

Conclusion
The Pi can generate pulses fast enough to control a servo, but the operating system means that the pulses are not terribly reliable. The process may get interrupted at any time, lengthening the pulses, resulting in the jitter that you see.

If you want true accurate control, then you probably need to have the Pi delegate looking after the servos to an Arduino, as I do in my Pi with Arduino over USB blog post.


About the Author
These are my books. Click on the image below to find out more about them.





                                                                                                                           

Monday, February 18, 2013

Raspberry Pi and Breadboard (Raspberry Leaf)

I thought I would share this little helper I have made to simplify using the Pi with jumper wires.

If you are using your Raspberry Pi with Breadboard, and you have lots of connections to make, then the Pi Cobbler from Adafruit is pretty neat. However, sometimes you only need to make a couple of connections and the Cobbler is overkill and a few Male to Female jumper leads will do just fine.



The drawback with using Male to Female jumpers direct onto the GPIO is that you then have to count down the pins trying to find the pin you need, because nothing is labelled. Matching a diagram of the pinout to the actual pins is not easy and mistakes can be made.

Enter the Raspberry Leaf! Okay, so its just a bit of paper, with all the pin labels on. The image for this is at the end. Just save it, print it out, and cut around the border. It's saved at 300 dpi.

To fit it onto the GPIO pins, I found it easiest to make the holes first by placing it over some breadboard and pushing a header pin through each hole in turn.

Pushing it all the way down to the bottom of the GPIO connector needs tome help from a plastic tool - or if you turn off your Pi and, use a small screwdriver. DON'T DO THIS WITH THE Pi POWERED UP!!!

This has now become a permanent fixture on my prototyping Pi.

All the numbers refer to the BCM GPIO number, so if you are using the RPi.GPIO library then be sure to set the mode to BCM using the function setmode.

I hope you find it useful.

This is the template for the original R1 board saved at 300dpi - click it to open it in its own window. Also, here is a PDF version, that's hopefully easier to print the right size.

This is the template for the current R2 boards. PDF Version. Note that this was updated 20 Feb, 2013, as I had pins 2, 3 and 27 wrongly labelled!

BUY
If you would prefer to buy your Raspberry Leaves ready made, printed on durable glossy paper and ready cut and drilled, then you can buy them from my website (www.monkmakes.com).


About the Author
These are my books. Click on the image below to find out more about them.





Saturday, January 18, 2014

Raspberry Pi Electronics Starter Kit

One of the most frequently asked questions of me is 'where can I buy the parts for X' where X is one of the project in my books.

In an attempt to remedy this situation, my partner Linda and I have started on little on-line store (monkmakes.com) to make and sell things related to by books. That will include the books themselves, signed by the author if you wish (this is very good for my ego) but also kits of parts.

The web store is based in the UK, but we have no problems with shipping world-wide. Its very early days and we are still finding our way. So if you have any suggestions on what else we should sell, please contact linda@monkmakes.com.

Our first product is an electronics starter kit for the Raspberry Pi. 



This is breadboard-based and although it has the parts needed to build Recipes 9.1, 9.2, 9.3, 9.9, 9.12, 11.1, 11.2, 12.2 in my Raspberry Pi cookbook, it also includes 10 project cards that give you the breadboard layouts for ten projects:

  • Make an LED blink
  • Make 2 LEDs blink
  • RGB Colour Display
  • Thermometer
  • Thermometer Plus
  • Reaction Timer
  • Light Meter
  • Light Harp
  • Proximity Detector
  • Email Notifier
The projects are also accompanied by a download of Python programs to support the projects and provide user interfaces.

The kit includes the following components:

  • 470Ω resistor
  • 1kΩ resistor (1)
  • 4.7MΩ resistor (1)
  • Red LED (2)
  • RGB LED (1)
  • Switch (2)
  • 330NF capacitor (1)
  • thermistor (1)
  • photoresistor (1)
  • buzzer (1)
  • raspberry leaf (1)
  • breadboard (1)
  • male to male jumper leads (10)
  • male to female jumper leads (10)
  • 10 easy to use instruction cards
The Raspberry leaf (which we also sell separately) is a nicely printed template that has holes where the GPIO pins fit, making it easier to know which pin is which. I originally blogged about this back in February last year and it was a huge hit. You can of course just download and print the PDFs, but if you want something ready made, then we sell them ready made.


Anyway, please take a look at our store and let us know what else you would like to see us selling.


About the Author
These are my books. Click on the image below to find out more about them.





Friday, November 23, 2012

Using .NET Gadgeteer Modules with Arduino - Relay

The .NET Gadgeteer system has spawned a wide range of low cost and useful modules form places like GHI Electronics and Seedstudio.

I have a load of Gadgeteer modules, sitting in a cupboard, so I thought it would be good to see how hard it would be to use them with an Arduino. I decided to start with a nice easy one, this relay module from Seedstudio. It has four relays, each with an indicator LED.

The Gadgeteer modules are all connected by 10 way ribbon cable connectors. So clearly, the first thing we need is to make a lead that we can use to connect the module to breadboard.

I cut a lead in half and stripped the 10 wires from the half of the lead with the connector notch to the left. This turned out to be pretty easy. I was rather expecting it to go wrong and the leads end up all sorts of different lengths - but the wires stripped really easily.

I found that using a craft knife to separate the leads helped.
I then tinned the stripped wires and soldered them to a length of 10 pin header stuck into breadboard to stop it moving.

There we go, a lead that we can use with any Gadgeteer module.

The Gadgeteer system has many different types of pinout for these connectors. The relay module uses a type-Y socket, which is a general purpose IO arrangement. There are other types for serial, USB, I2C, analog and all sorts. They all use the same connectors, but have different pinouts.

You can find full details of all the pinout options here.

The pinouts for the type-Y are as below:



Here is a section of the Eagle schematic for the relay module (Open Source).

Although Gadgeteer modules are often 3.3V, this design will have no problem using 5V levels, so all looks promising. The control pins for the relays are connected to Gadgeteer pins 3, 4, 5 and 6.

The schematic shows the relay coils being supplied from 5V (pin 2), but testing with a multimeter, I found that the 'top' connection of the relay coil was actually connected to pin 1 (3.3V). I don't really understand this discrepancy, but no problem, in this case we can supply 5V from the Arduino to pin 1 of the module. That would be a bad thing to do for most types of Gadgeteer module - be Warned!

Here is the wired up breadboard:



  • Pin 1 of the Gadgeteer connector goes to Arduino 5V
  • Pin 10 of the Gadgeteer connector goes to Arduino GND
  • Pins 3, 4, 5 and 6 of the Gadgeteer connector goes to Arduino D2, D3, D4 and D5 respectively
Here is a little test sketch that lets you turn each Relay on and off using the Serial Monitor.




// Gadgeteer Relay Board

int relayPins[] = {2, 3, 4, 5};

void setup()
{
  for (int i = 0; i < 4; i++)
  {
    pinMode(relayPins[i], OUTPUT);
  }
  Serial.begin(9600);
  while (!Serial);
  Serial.println("A, B, C, D to turn relay on");
  Serial.println("a, b, c, d to turn relay off");
}

void loop()
{
  if (Serial.available())
  {
    char ch = Serial.read();
    if (ch >= 'A' && ch <= 'D')
    {
      digitalWrite(relayPins[ch - 'A'], HIGH);
    }
    if (ch >= 'a' && ch <= 'd')
    {
      digitalWrite(relayPins[ch - 'a'], LOW);
    } 
  }
}



Conclusion
Now that I have a lead, I need to think about which Gadgeteer module to try next!

Perhaps one of the I2C modules?

                        
About the Author
These are my books. Click on the image below to find out more about them.




                                                                 

Monday, September 23, 2024

Are the Pico 2 (RP2350) GPIO pins broken?

TLDR; A little bit, yes, but it probably doesn't matter.

The new Raspberry Pi Pico 2 mostly represents a bump in performance and memory. 

A welcome feature of the release, for authors such as myself, is that the functioning of the GPIO pins and the pinout remains the same as the original Pico 1, as does the most used microPython programming environment,  

So, it was a surprise to find various reports of a hardware bug affecting GPIO pins. My main concern was, does this affect the way GPIO pins are used in the examples for my book Programming the Pico, as well as the instructions for our Pico electronics kit.?



The Problem

You can find the formal explanation of the bug in the RP2350's datasheet - on page 1341 (yup, perhaps don't start looking for it on page 1). The detail is somewhat complex, affecting only the situation where a GPIO pin (any) is used as a digital input with the internal pull-down resistor enabled.

Digital Input (Internal Pull-UP resistor enabled)

Before we look at the problem scenario, let's try out the more common situation where a GPIO pin is sued as a digital input with the internal PULL_UP resistor enabled.


Here is the example code (from Programming Pico).

from machine import Pin

from utime import sleep

switch = Pin(10, Pin.IN, Pin.PULL_UP)

while True:

    print(switch.value())

    sleep(0.1)

In this scenario, the internal pullup resistor is enabled by the line of code:

switch = Pin(10, Pin.IN, Pin.PULL_UP)

.. this keeps the GPIO pin (10 in this example pulled up to the 3.3V supply voltage, registering as a 1 when it's value is read. This resistor, that is built into the PGIO hardware of the RP2350, has a value of a few 10s of kΩ. When the switch is pressed, this relatively weak pull-up is overpowered as the switch connect the GPIO pin to GND (0V). The input then registers as a value of 0 when read.

When you run the program, you will see something like this.

By default, the value shown in the Shell area is 1, but when the switch is pressed, it changes to 0. Here's the breadboard layout using parts from the MonkMakes Electronics Kit 1 for Pico.


So, in short, this works just fine. No problem here.


Digital Input (Internal Pull-DOWN resistor enabled)

Some microcontrollers do not even have the option of a built-in 'pull-down' as opposed to 'pull-up' resistor. Generally switches on digital inputs connect the GPIO pin to GND (0V) when pressed. This is the safest option, as generally boards only have one GND of 0V, but may have several supply voltages (3.3V and 5V -- in the case of a Pico). Connecting 5V to a 3.3V digital input can destroy that input on may GPIO designs, so it's much safer to use pull-up resistors and cope with the inverted logic of 0 meaning pressed and 1 meaning not pressed in your code.

Having said that, the feature is there, so people will make use of it. So, here is the problem situation, of digital inputs with a built-in pull-down resistor.


This is shown on breadboard, here, where the switch is now between GPIO 10 and 3.3V on the Pico. There are also 2 more leads connected to a DMM acting as a voltmeter measuring the voltage at GPIO 10.



Here is the code. All that's changed is that Pin.PULL_UP has become Pin.PULL_DOWN

from machine import Pin

from utime import sleep

switch = Pin(10, Pin.IN, Pin.PULL_DOWN)

while True:

    print(switch.value())

    sleep(0.1)

When I run the program, there is immediately a problem apparent. The Shell is reporting values at the GPIO pin of 1. This should be 0, because the switch is NOT pressed and the pull-down resistor is enabled. The voltmeter is reading 2.11V, which is above the threshold for being a high input (reading a value of 1).

If I then press the button, there is no change to the output in the Shell, it is still saying 1, but the voltage at the PGIO pin is now 3.3V as you would expect.

So, if the GPIO acting as an input, actually suddenly looks like an output at 2.11V, how much current flows through the GPIO pin when we press the switch connecting it to 3.3V?!

Connecting the multimeter to the GPIO pin to measure the current drawn, then the answer is a reassuringly tiny current of just 60µA. So, we are not going to burn anything out.

So, in short, don't try and use the built-in pull-down resistors, they don't work. 

Conclusion

The internal pull-up resistor feature of digital inputs works just fine, but the pull-down feature does not work. I can live with that, because it's better practice to just use pull-up resistors.

So, should you buy a Pico 2? Yes, unless you really ned to use internal pull-down resistors.

Note that my Pico 2, was bought in September 2024, so you might find that this has been fixed in the silicon that you have.

Sunday, August 5, 2012

Review: 4-digit 7-segment LED and RTC from Adafruit

In this review, I thought I would combine Adafruit's 0.56" 7-segment LED backpack and display and their DS1307 RTC (Real Time Clock) board. The obvious choice for such a combination is to make a simple clock!

Note that my pictures make the display look a little washed out. It wasn't, it was very bright. This is juts an effect of my photography lighting setup being even brighter.

Both modules are I2C and therefore just require two data pins along with GND and 5V. So, for anyone who has done their own multi-digit 7-segment LED multiplexing wiring up the breadboard becomes beautifully simple.

0.56" 7-Segment Backpack and Display

This comes as a kit of parts that need to be soldered together. Well actually just the PCB, header pins and the LED display itself. The surface mount chip is already soldered for you. 
Beginners will have no trouble with this, and Adafruit provide a very detailed construction guide.


DS1307 Real Time Clock breakout board kit

The RTC module is also supplied in kit form and would also suit someone new to soldering. Once again, the instructions are excellent. Showing you the right order in which to solder the components in a step-by-step manner with clear photographs as illustrations.


I got an extra resistor, but then I got more pin headers than I needed on both kits, so I think maybe its the Adafruit approach to err on the side of caution. Once assembled the Lithium battery (which should last years) can be inserted so that the module remembers the time.


Making a Digital Clock

Making the digital clock was delightfully simple, and basically merges together bits from the example scripts for the libraries for each module.

The Adafruit library for the display is nice, very easy to use. Their installation guide explains where to get it from github, along with a supporting library that it requires. 

The RTC module uses the Jee Lab's RTClib.

As normal with libraries, unzip the folders into your Arduino 'libraries' directory and then restart the Arduino IDE for it to pick them up. If you get an error message, as Arduino starts, about the libraries having invalid names, you missed the step of renaming the Adafruit libraries after unzipping them. Just rename the folders to remove the 'funny' characters and call them 'AdafruitLEDBackpack' and 'AdafruitGFXLibrary'.

Wire up your breadboard like this:



Coming from the Arduino, the leads are:
Red - 5V (Vcc)
Black - GND
Orange - A4 (SDA - data)
Yellow - A5 (SCL - clock)

These all just go to the pins with the same names on the two modules!

Paste the following sketch into a new Arduino window and upload it to your board. It will set the RTC to the time at which the sketch was compiled and uploaded. So, if your computer picks up its time from the Internet, that will be pretty accurate.
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include "RTClib.h"

RTC_DS1307 RTC;
Adafruit_7segment disp = Adafruit_7segment();

void setup() 
{
  Wire.begin();
  RTC.begin();
  if (! RTC.isrunning()) 
  {
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  disp.begin(0x70);
}

void loop() 
{
  disp.print(getDecimalTime());
  disp.drawColon(true);
  disp.writeDisplay();
  delay(500);
  disp.drawColon(false);
  disp.writeDisplay();
  delay(500);
}

int getDecimalTime()
{
  DateTime now = RTC.now();
  int decimalTime = now.hour() * 100 + now.minute();
  return decimalTime;
}


Conclusion
These modules make life easy and free up Arduino pins for other uses. 

Great supporting documentation telling you all you need to know to get you started and more. Two very useful modules at not a bad price. 

Never again, will I be messing around multiplexing a load of LEDs with transistors for  the common anode and having the Arduino run off its feet refreshing! This is much easier!

[disclosure: These models were provided by Adafruit to me F.O.C]


About the Author
These are my books. Click on the image below to find out more about them.




                                                                                                                           

Friday, February 21, 2014

Raspberry Pi Fridge Minder: receive an email when the door is opened

I decided to see what other kinds of project can be made from the MonkMakes Raspberry Pi Electronics Starter Kit, that I designed.


The kit comes with project cards and a link to download the accompanying Python scripts. And projects already include a light meter and email notifier, so I decided to combine these two projects into one and make something that will send an email whenever the fridge door is opened. 


This is particularly timely as the MonkMakes team are trying to loose some weight at the moment. The paper template on the Raspberry Pi GPIO connector is called a Raspberry Leaf.

It turned out to be pretty straightforward. The breadboard layout is shown below:


BTW. A big thank you to Fritzing for a great design tool.

The photoresistor needs to be inside the fridge, so we can use two of the male to female jumper leads. This will of course also provide us with proof to the eternal question of whether the light really goes off when you close the fridge door.

You can see the completed breadboard and Pi below.


To install the program on the Raspberry Pi, you probably want to connect using SSH (see this Adafruit tutorial). Run the command "nano fridge.py" and paste the following code into the editor.

# fridge.py

import RPi.GPIO as GPIO
import time, math
import smtplib, time

SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587

GPIO.setmode(GPIO.BCM)

a_pin = 18
b_pin = 23
led_pin = 24

GPIO.setup(led_pin, GPIO.OUT)
GPIO.output(led_pin, False)

def discharge():
    GPIO.setup(a_pin, GPIO.IN)
    GPIO.setup(b_pin, GPIO.OUT)
    GPIO.output(b_pin, False)
    time.sleep(0.01)

def charge_time():
    GPIO.setup(b_pin, GPIO.IN)
    GPIO.setup(a_pin, GPIO.OUT)
    GPIO.output(a_pin, True)
    t1 = time.time()
    t2 = t1
    while GPIO.input(b_pin) == 0:
        t2 = time.time()
        if (t2 - t1) > 1.0:
            return 0
    return (t2 - t1) * 1000000

def analog_read():
    discharge()
    return charge_time()


def send_email(username, password, recipient, subject, text):
    print(username, password, recipient, subject, text)
    smtpserver = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
    smtpserver.ehlo()
    smtpserver.starttls()
    smtpserver.ehlo
    smtpserver.login(username, password)
    header = 'To:' + recipient + '\n' + 'From: ' + username
    header = header + '\n' + 'Subject:' + subject + '\n'
    msg = header + '\n' + text + ' \n\n'
    smtpserver.sendmail(username, recipient, msg)
    smtpserver.close()

username = raw_input("Sending gmail address? ")
password = raw_input("Sending gmail password? ")
recipient = raw_input("Send email to? ")
subject = "FRIDGE VIOLATION"
message = "Someone just opened the fridge door!"

while True:
    reading = analog_read()
    if reading > 0: #dark so timeout
        GPIO.output(led_pin, True)
        send_email(username, password, recipient, subject, message)
        time.sleep(120)
        GPIO.output(led_pin, False)
    time.sleep(0.1)

You can test out the program without installing it on your fridge. Start the program using the command:

sudo python fridge.py

There may be a few warnings about GPIO channels being in use, which you can ignore. Cover the light sensor with a cloth or place it somewhere where it will be completely dark.

You will be prompted for your gmail email address, password and who you want to be sent an email when the fridge door is opened.


$ sudo python fridge.py 
Sending gmail address? myname@gmail.com
Sending gmail password? jkshdgfkayig
Send email to? youremail@somemail.com

When its running, you can uncover the sensor and you should see some trace that the email has been sent. Similarly, any errors will appear. 

The light sensor having fairly thin wires attached can just be shut in the door.




You may be interested in the books I have written about the Raspberry Pi.


Monday, June 10, 2024

New Book on ESP32 and MicroPython

I've had several requests, over the years, from readers of my books for me to write a book on the ESP32. Yes, there is lots of information out there on the Internet, but it's nice to have everything in one place, and also tried and tested on a variety of ESP32 boards. So, somewhat late to the party, I've finally written one.


I've based the book on MicroPython using Thonny. Thonny helps a lot with the ESP32. Not only is it a nice simple Python editor for those new to coding, but it also integrates with the esptools software, making it easy to flash your ESP32 board with the MicroPython firmware, without having to use the command line.


One of the biggest challenges in writing a book about ESP32 is the shear number of different ESP32 boards available.


This book is two-thirds Python programming, which applies to and ESP32 board and one third electronics using solderless breadboard. When it comes the electronics side of things, I provide breadboard layouts for two of the most popular ESP32 boards, the ESP32 Lite and the DevKit 1.


The paperback version of the book is printed in monochrome to keep the costs down, but a color ebook version is also available.

The book is available on Amazon.com.


In the future it will also be available from some of MonkMakes resellers and you can find details, here:

https://monkmakes.com/book_prog_esp32

All the example code is available on github here. https://github.com/simonmonk/prog_esp32

The books webpage is here: https://simonmonk.org/esp32



Friday, February 5, 2016

A Simple LED Clock using Spark Core or Particle Photon

Having a spare Spark Core doing nothing, it struck me that it would be very easy to pair it up with a large 4 digit 7 segment I2C Adafruit display that I had and make a clock. What's more, because the Spark Core is connected to the Internet via my home network it can get its time from a time server and always be accurate.



Hardware


To make this build, you will need:


  • A Particle Photon or Spark Core
  • I2C backpack LED display (Adafruit product ID 878 or 1270)
  • Half breadboard
  • 2 x 4.7k resistors
  • 5 x male to male jumper wires
I used Adafruit's large display (1270) which has an extra pin to the left of the + pin that supplies power for the control logic, separate to the LED power. The breadboard layout below will work for the large display and the smaller display, just make sure that whichever display you use, the yellow lead goes to the C connection of the display.

The displays are also available in other colors if you check Adafruit's website


Software

Go to http://particle.io and select the BUILD option to open the web IDE. 

Create a new 'App' and call it Clock.

This project requires the SPARKTIME and ADAFRUIT-LED-BACKPACK LIBRARIES, so click on the libraries button, find each of these libraries in turn and click USE THIS LIBRARY selecting your new Clock app when asked to select the app.

Now you can paste the following code into your App. Note that the includes should already be there if the libraries have been imported correctly.

You will need to change your time zone offset on the last line of setup.

That's it - the display should start as soon as the Photon or Core resets. 



#include "SparkTime/SparkTime.h"
#include "adafruit-led-backpack/adafruit-led-backpack.h"

Adafruit_7segment matrix = Adafruit_7segment();
UDP UDPClient;
SparkTime rtc;

unsigned long currentTime;
unsigned long lastTime = 0UL;
String timeStr;
int colon = false;

void setup() {
  matrix.begin(0x70);
  matrix.setBrightness(15);
  rtc.begin(&UDPClient, "north-america.pool.ntp.org");
  rtc.setTimeZone(0); // gmt offset
}

void loop() {
    
  currentTime = rtc.now();
  int min = rtc.minute(currentTime);  
  int hour = rtc.hour(currentTime);
  matrix.print(hour * 100 + min, DEC);
  colon = ! colon;
  matrix.drawColon(colon);
  matrix.writeDisplay();
  delay(500);
}


If you enjoyed making this project, and want to learn more about programming and using the Photon, check out my book on the Photon.