Skip to content

Teaching microcontrollers

My ten year old niece did some soldering today!

As an introduction to electronics, microcontrollers, soldering and programming we decided to make a traffic light!
This is the result:

Here’s the code. Not much to it, but my niece wrote the logic part 🙂

-- ------------------------------------------------------
-- Title: Blink-a-led of the Microchip pic12f1822
-- Author: Rob Hamerling, Copyright (c) 2008..2010, all rights reserved.
-- Adapted-by:
-- Compiler: 2.4n
-- This file is part of jallib  (
-- Released under the BSD license (
-- Description:
-- Sample blink-a-led program for Microchip PIC12f1822.
-- Sources:
-- Notes:
--  - File creation date/time: 15 Nov 2010 20:04:23.
-- ------------------------------------------------------
include 12f1822                    -- target PICmicro
-- This program assumes that a 20 MHz resonator or crystal
-- is connected to pins OSC1 and OSC2.
-- (unspecified configuration bits may cause a different frequency!)
pragma target clock 1_000_000     -- oscillator frequency
-- configuration memory settings (fuses)
pragma target OSC      INTOSC_NOCLKOUT               -- HS crystal or resonator
pragma target PLLEN  P1           -- PLL off
pragma target WDT      disabled     -- no watchdog
pragma target DEBUG    disabled     -- no debugging
pragma target LVP      disabled     -- no Low Voltage Programming
pragma target MCLR external        -- reset externally
-- These configuration bit settings are only a selection, sufficient for
-- this program, but other programs may need more or different settings.

include delay

OSCCON = 0b_0101_1011

enable_digital_io()                -- make all pins digital I/O
-- Specify the pin to which the LED (with serial resistor!) is connected:
alias   groen      is pin_A0
pin_A0_direction =  output

alias   oranje      is pin_A1
pin_A1_direction =  output

alias   rood      is pin_A2
pin_A2_direction =  output

groen = off
oranje = off
rood = off
forever loop
   groen = on
   groen = off
end loop
Published inElectronics

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *