Saturday 8 October 2016

2016 JOTA source code for Bike Light

// 2016 JOTA project for Sydney North Region.
// Morse Code Timing - https://en.wikipedia.org/wiki/Morse_code

// Digispark ATTiny85 Boot Loader

#define LED1 0
#define LED2 1
#define LED3 2
#define LED4 5

#define dit_time 200
#define dah_time dit_time * 3

void setup() {
  // put your setup code here, to run once:
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  flash(LED1, 500);
  flash(LED2, 500);
  flash(LED3, 500);
  flash(LED4, 500);

  flicker(LED1, 100, 4);
  flicker(LED2, 100, 4);
  flicker(LED3, 100, 4);
  flicker(LED4, 100, 4);

delay(500);

//Morse

// J
dit(); dah(); dah(); dah(); letter_space();

// O
dah(); dah(); dah(); letter_space();

// T
dah(); letter_space();

// A
dit(); dah();letter_space();

word_space();


}
// Sub Routienes

// Morse Dit
void dit() {
  all_on();
  delay(dit_time);
  all_off();
  delay(dit_time);
}

// Morse Dah = 3 x Dit.
void dah() {
  all_on();
  delay(dah_time);
  all_off();
  delay(dit_time);
}

// Letter Space = 3 x Dit
void letter_space() {
  delay(dit_time * 3);
}

// Morse Word Space
void word_space() {
  delay(dit_time * 7);
}

// All LEDs On.
void all_on(){
  digitalWrite(LED1, HIGH);
  digitalWrite(LED2, HIGH);
  digitalWrite(LED3, HIGH);
  digitalWrite(LED4, HIGH);
}

// All LEDs Off.
void all_off(){
  digitalWrite(LED1, LOW);
  digitalWrite(LED2, LOW);
  digitalWrite(LED3, LOW);
  digitalWrite(LED4, LOW);
}

// Flash LEDx on for a duration of wait.ms.
void flash(int pin, int wait)
{
  digitalWrite(pin, HIGH);
  delay(wait);
  digitalWrite(pin, LOW);
}

// Flicker LEDx for period wait n times.
void flicker(int pin, int wait, int times)
{
  int i;
  for (i = 0; i <= times; i++) {
    flash(pin, wait);
    delay(wait);
  }
}

Sunday 7 August 2016

Installing Arduino + Digispark on Linux Mint18

This was a little challenge. Where would we be without Google.

The advice on the Digistump website did NOT work.


1. Install the Arduino environment. https://www.arduino.cc/en/Guide/Linux

2. Install Digistump additional hardware https://digistump.com/wiki/digispark/tutorials/connecting

3. Per https://digistump.com/board/index.php/topic,106.msg106.html#msg106

Create a file named /etc/udev/rules.d/digispark.rules with the following line in it:

SUBSYSTEM=="usb", ATTR{idVendor}=="16d0", ATTR{idProduct}=="0753", MODE="0660", GROUP="dialout"


4. Add permission for dialout so other Arduino boards will work. 
https://www.arduino.cc/en/Guide/Linux#toc9

sudo usermod -a -G dialout <username
>

where <username> is your linux user name. You will need to log out and log in again for this change to take effect.


Note: To reload the udev rules use: 
sudo udevadm control --reload-rules

JOTA 2016 Bike Light.

The project this year is a bike light.

The project uses previously purchased bezels,

The original circuit was a transistor oscillator driving 3 LEDs from a 9v Battery.

Like all things, I can resist making the programmable.

The 2016 version uses an ATTiny85 microprocessor based module based on a Digispark variant,
http://digistump.com/products/1

It contains 4 ultrabright red LEDs. The flashing of the LEDs is programmed on the microcontroller.

The JOTA version is from http://www.banggood.com/ATTINY85-Mini-Usb-MCU-Development-Board-For-Arduino-p-971122.html

This board is not shipped with a boot loader. A programing board with pogo pins will be used to pre-program each board with the correct firmware and fuse settings.

The hex file which contains the USB boot loader and the bike light program can be downloaded from here.

Fuse settings are:  efuse:0xfe hfuse:0x5f lfuse:0xf1
These settings disable the reset pin functionality in order to obtain 4 outputs for the LEDs

The Arduino programing environment, along with the digispark hardware add-on to the IDE is used to program the device.

This link has instructions for setting up the development environment.
 https://digistump.com/wiki/digispark/tutorials/connecting

There are additional unused holes on the PCB to accommodate different style ATTiny85 modules available. Care needs to be taken during assembly to use the correct holes for the modules purchased.

There is also a row of 4 holes providing the option of adding a grove style header for additional inputs and outputs.






Source Code: (Draft) To have morse added for JOTA weekend.

#define LED1 0
#define LED2 1
#define LED3 2
#define LED4 5

// Digispark ATTiny85


void setup() {
  // put your setup code here, to run once:
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  flash(LED1, 500);
  flash(LED2, 500);
  flash(LED3, 500);
  flash(LED4, 500);

  flicker(LED1, 100, 4);
  flicker(LED2, 100, 4);
  flicker(LED3, 100, 4);
  flicker(LED4, 100, 4);

}

void flash(int pin, int wait)
{
  digitalWrite(pin, HIGH);
  delay(wait);
  digitalWrite(pin, LOW);
}

void flicker(int pin, int wait, int times)
{
  int i;
  for (i = 0; i <= times; i++) {
    digitalWrite(pin, HIGH);
    delay(wait);
    digitalWrite(pin, LOW);
    delay(wait);
  }
}



Saturday 26 March 2016

Outlander Adventures. - Links and Nudge bar installation



Bumper removal 2014 Outlander

That was a mission!
Tips:
Remove the 2 under body protection panels  starting with the rear most panel beneath the engine.
Admire the location of the oil filter!
Disconnect fog light cable and headlight hose. There is a quick-release on the hose.




Installing an Aux input for the stereo

To enable Aux input press and hold the Info and Map buttons and find the menu.

Possible front parking sensor part numbers

8651A056 8651A056HA 

Close up photos

The LH connector is for the fog lights. The RH connector may be for the front parking sensors.