Intro and Outro video insert for Kaaos Gear

A quick video insert I made for company called Kaaos Gear, a company who makes high quality gear for military and law enforcment. The video is shown at the start and end of a company showcase video.

This was a fun project, I like the gloomy and eerie feeling. The glitch effect was done by masking in Adobe After Effects.

I did not design the logo or slogan and take no credit.

You can check the company from the links below

http://www.kaaosgear.com/

https://www.facebook.com/kaaosgear/

https://instagram.com/kaaosgear/

Update Dota2_Timer

Project Dota2 Timer

For our final project on the course, our project is Dota2Timer made in collobration with Antti Eloranta.

Dota 2 timer, clock which is integrated to a map. Map has:

  • 2 leds indicating ‘runes’ every 2 minutes (2,4,6.etc)
  • 2 leds indicating ‘jungle’ every minute, + 1 additional time at 00:30
  • 2 leds indicating ‘catapult’ every 3,5 minutes.
  • 1 button to indicate ‘roshan’, get current time and add +8 min and display.
  • 1 LCD display to display information and the clock.

Hardware:

  • LCD screen (this one is from the Arduino Starter kit)
  • 6 LEDs(2 white,2 blue, 2 red)
  • 3 potentiometers(LCD contrast, LCD brightness, 1 for the ‘role’ mapped to 3 values.
  • 1 on/off switch
  • 1 button
  • WIRE(we estimated 40 wires)
  • Case(we chose wooden and bought it from a shop)
2014-03-14 12.10.45
The casing we bought from Hong Kong-deparment store for 7€
CAM00845
Drilling the Arduino USB-hole to the casing.
2014-03-14 17.08.25
Testing the LCD and the Code

CAM00004

CAM00081
First we drilled a hole, then cleaned it up with a hours of sand paper
CAM00079
Desperation. Antti Eloranta(left) & Péter Takács(right)
CAM00220
Fitting the PM
CAM00094
LCD fitted to the box.

2014-03-14 22.12.352014-03-14 20.20.10

Final Product

2014-03-16 21.59.07 2014-03-16 21.59.54 2014-03-16 22.00.39 2014-03-16 22.00.49

All photos

Source

Serial monitor

Write to Serial

First, you must initialize Serial monitor

  Serial.begin(9600);

This will initalize Serial monitor at 9600 bauds. After this it should be natural write something there. You can do this by

  Serial.println(“Text”);

or

  Serial.println(Variable);

With these tools now at hand, I modified the Blink (Helloworld) to this:

int led = 13;

void setup() {
pinMode(led, OUTPUT);
Serial.begin(9600);
}

void loop() {
digitalWrite(led, HIGH);
Serial.println(“High”);
delay(1000);
digitalWrite(led, LOW);
Serial.println(“Low”);
delay(1000);
}

Now to view the serial monitor. The serial monitor can be found in Tools -> Serial monitor, or Ctrl+Shift+M

Screenshot - 03092014 - 02:51:05 PM

Screenshot - 03092014 - 02:52:00 PM

How to read value from input & print to serial

This is good for debugging. I started by hooking a potentiometer (you can look up my Servo post for instructions on how to hook up potentiometer). I put my Analog.in in A0 in the Arduino board.

After further modifying the previous code, this code light’s up a led after potentiometer has passed its medium. Bold parts are new. Some parts are deleter alltogether.

const int analogInPin = A0;
int sensorValue = 0;
int outputValue = 0;
int led = 13;

void setup() {
pinMode(led, OUTPUT);
Serial.begin(9600);
}

void loop() {
  sensorValue = analogRead(analogInPin);     
  outputValue = map(sensorValue, 0, 1023, 0, 255); //map the value of the pm to 0-255
  Serial.print(“outputValue = “);   
  Serial.println(outputValue);   
if(outputValue > 127){
    digitalWrite(led, HIGH);               
  }
  else{
    digitalWrite(led, LOW);  
  }
  delay(100);
}

How to control Arduino with Serial monitor input

In this part I detach my potentiometer and use only Blink setup(nothing connected)

int led = 13;
char message = ‘ ‘;

void setup() {
pinMode(led, OUTPUT);
Serial.begin(9600);
}

void loop() {

while(Serial.available() > 0){
message = Serial.read();
}

if(message == ‘y’){
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
}
else{
digitalWrite(led, LOW);
}
delay(100);
}

If charecter y is written in the serial monitor, the led will blink as long as some other character is typed. The area where the input is made:

KUVA

How to control Arduino with Python

import serial

arduino = serial.Serial(‘/dev/ttyACM0’, 9600)

arduino.write(‘y’)

Final project ideas for Arduino Uno

In the course ‘Protoype building’ we have to make a final project. Here are some ideas I have been thinking.

MIDI-Controller

My first pick, as I would need this in my work.
Control your sequencer or DAW with a midi controller. This has been made numerous times, but the problem
customizing your controller. Project would need:

  •  Large amount of buttons
  •  Potentiometers / knobs ALOT
  •  Maybe a LCD display
  • Swipe wheel

Example of a market leading DJ MIDI-Controller

© Native Instruments

Dota Timer

Dota 2 timer, clock which is integrated to a map. Map has:

  • 2 leds indicating ‘runes’ every 2 minutes (2,4,6.etc)
  • 2 leds indicating ‘jungle’ every minute, + 1 additional time at 00:30
  • 1 one button to start a different clock, and 1 led to indicate time after button press > 5 minutes
  • 1 led to indicate every 7 minutes a ‘special wave’ is incoming.
  • 1 LCD display to display information and the clock.
  • 1 piezo speaker to further indicate the timings.

One idea would be the leds would blink 3 times 6 seconds before the time, and a piezo tone playing at the
exact time. This would be a training tool and in time would become useless when yourself know the timings.
Problem with this project is it is too easy, and would not be the best showcase of all the skills I have
learned. We have a made a prototype of this project already with Antti Eloranta. Here is a video in case
you missed it in my last post:


Breathalyzer
Breathalyzer meters cost a lot, and making your own with Arduino is cheap. A project would consist of Breathalyzer meter and LCD screen, which displays the current estimate of % alchocol.

Smart Workspace Lamp
A lamp covering a desktop, that would react to the movements on the desk. We would use ultrasonic sensors to detect movement on the desk and move the lamp accordingly so the user would not have to put their thoughts aside just to adjust their lamps position. This project would need:

  • 3-4 Ultrasonic sensors (maybe a solution to detect movement on a larger area than just a linear path)
  • Continuous/180degree turning servo.
  • A lamp.

Dice
Button would calculate math.random between 1-6 and display the results with LCD or 6 LEDS. This could be used to make a game with the breathanalyzer, the dice number could be multiplied by the % of alchocol in the blood.

Air freshness indicator

A arduino project usable at bars/nightclubs which have smoking rooms. There would be a board of leds indicating the amount of carbonoxide in the air.Purpose if the project would recommend smokers to consider coming back when there is more breathable air available – making the smoking room a bit fresher and also making the smokers understand how the amount of air really reflects on how it feels to be inside that room. We would need:

  • CO2 – sensor
  • Around 10 leds
  • Arduino

Extra: LCD display to give even more accurate values of the carbon oxide amounts in the air inside that room.

Dota 2 Timer – Arduino Uno with LCD

This is a work of progress. This work is made in collobration with Antti Eloranta. We will update and explain the code later.

// include the library code:
#include <LiquidCrystal.h>
int led = 13;
int firstjungle = 0;
int junglecreepN = 1;
int firstTime = 1;

long day = 86400000; // 86400000 milliseconds in a day
long hour = 3600000; // 3600000 milliseconds in an hour
long minute = 60000; // 60000 milliseconds in a minute
long second = 1000; // 1000 milliseconds in a second
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
// set up the LCD’s number of columns and rows:
pinMode(led, OUTPUT);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.clear();
}

void firstJungle(){

firstjungle = 1;
lcd.clear();
lcd.print(junglecreepN);
lcd.print(“. Jungle Creeps”);
junglecreepN++;
for(int i = 0; i<6; i++){
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(250);
}
lcd.clear();
lcd.print(“Dota_Timer”);
lcd.setCursor(13, 0);
// print the number of seconds since reset:
lcd.print(millis()/1000);

}

void loop() {
lcd.print(“Dota_Timer”);
long timeNow = millis();
int minutes = ((timeNow % day) / minute) ;
int seconds = (((timeNow % day) % hour) % minute) / second;
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(11, 0);
// print the number of seconds since reset:
//lcd.print(millis()/1000);
if (minutes<10){
lcd.print(“0”);
lcd.print(minutes);
}
else {
lcd.print(minutes);
}
lcd.print(“:”);
if (seconds < 10){
lcd.print(“0”);
lcd.print(seconds);
}
else{
lcd.print(seconds);
}

if(seconds == 30 && firstjungle == 0){
firstJungle();
}

if(seconds > 1){
firstTime = 0;
}
if(seconds == 00 && firstTime == 0){
lcd.clear();
lcd.print(junglecreepN);
lcd.print(“. Jungle Creeps”);
junglecreepN++;
for(int i = 0; i<6; i++){
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(250);
}
lcd.clear();
lcd.print(“Dota_Timer”);
lcd.setCursor(13, 0);
// print the number of seconds since reset:
lcd.print(millis()/1000);
}
else{
}
}

Control your servo with potentiometer

Requirements:

  • Any Arduino
  • Servo ( mine is 3001HB Analog Servo)
  • Potentiometer
  • 2leds
  • wire

My servo has 3 wires. I had to look up which one is which. Here is a picture and a explanation.

2014-02-20 15.30.32

BROWN – GND
RED  – 5V
YELLOW – SIGNAL

2014-02-20 15.33

2014-02-20 15.29.52
The setup
Screenshot - 02202014 - 01:44:21 PM
Images copyright Fritzing

First we have to get readings from the potentiometer. I loaded up the AnalogInOutSerial example to get the readings and made the connections as in the example.

After loading up the code I check the serial monitor to see if it responds to the potentiometer.  The default mapping of 0, 255 is good for my purpose so I decide to leave it in as it is. We have possible reading of 0-255 from the potentiometer now.  I intend to make it so that if potentiometer is rotated to the left, servo will do the same and same for the right. I half the 255 to 127 and make a if loop.

if(outputValue > 127){               // If PM is turned left
servo1.write(++pos);            // Go LEFT
delay(1);
}

If the output is more than half of the max output, tell servo to add 1 to pos. If less than half, deduct 1 from pos. I determined the default position of 90 in the variable init.

My servo is not a full rotatory servo, so we have to limit the possible move range. 0 is full left, 180 full right. 90 is center. I put a do while-statement inside the if.

if(outputValue > 127){               // If PM is turned left
do{
servo1.write(++pos);            // Go LEFT
delay(1);
}while(pos < maxLeft);             // While inside max value
}

I also added a totally unnecessary feature of lighting up a led when the max range is reached. This is done by adding another if else statement

if(pos >= maxRight){
digitalWrite(greenLed, HIGH);   // If servo reaches max angle, light up a led to indicate you a breaking it
}else{
digitalWrite(greenLed, LOW);
}

Below is the fully compiled code.

// Potentiometer controlling servo
// Péter Takács20/2/2014
// This example code is in the public domain.

#include <Servo.h>

Servo servo1;  // create servo object to control a servo

const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)
int pos = 90;                // Center position
int maxLeft = 0;
int maxRight = 180;
int greenLed = 4;
int yellowLed = 2;

void setup()
{
servo1.attach(9);  // servo pin
Serial.begin(9600); // init serial comm
pinMode(greenLed, OUTPUT);
pinMode(yellowLed, OUTPUT);
}

void loop()
{
sensorValue = analogRead(analogInPin);
outputValue = map(sensorValue, 0, 1023, 0, 255); // MAP THE POTENTIOMETER, LEFT = 0, RIGHT = 255

if(outputValue > 127){               // If PM is turned left
do{
servo1.write(++pos);            // Go LEFT
delay(1);
}while(pos < maxLeft);             // While inside max value
}

if(outputValue < 127){              // If PM is turned right
do{
servo1.write(–pos);           // GO RIGHT
delay(1);
}while(pos > maxRight);         // While inside max value
}

if(pos <= maxLeft){                // If servo reaches max angle, light up a led to indicate you a breaking it
digitalWrite(yellowLed, HIGH);
}else{
digitalWrite(yellowLed, LOW);
}

if(pos >= maxRight){
digitalWrite(greenLed, HIGH);   // If servo reaches max angle, light up a led to indicate you a breaking it
}else{
digitalWrite(greenLed, LOW);
}

// print the results to the serial monitor:
Serial.print(“sensor = ” );
Serial.print(sensorValue);
Serial.print(“\t output = “);
Serial.print(outputValue);
Serial.print(” position = ” );
Serial.println(pos);
delay(2);
}

Sources:

Tero Karvinen’s lessons in Haaga-Helia University of Applied Sciences

NOTE: All images (if any) used on this post were self-taken. Fritzing photos are made with Fritzing and is the property of Fritzing.

“This document can be copied and modified under the conditions of GNU General Public License. http://www.gnu.org/licenses/gpl.html

Guile theme with Piazo Arduino

/*
Melody

Plays a melody

circuit:
* 8-ohm speaker on digital pin 8

created 21 Jan 2010
modified 30 Aug 2011
by Tom Igoe

This example code is in the public domain.

http://arduino.cc/en/Tutorial/Tone

*/
#include “pitches.h”

// notes in the melody:
const int buttonPin = 7;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin
int soundPin = 2;
int melody[] = {
NOTE_DS4, NOTE_DS4, NOTE_D4, NOTE_D4, NOTE_DS4, NOTE_D4,
NOTE_DS4, NOTE_DS4, NOTE_D4, NOTE_D4, NOTE_DS4, NOTE_D4,
NOTE_DS4, NOTE_D4, NOTE_DS4, NOTE_D4, NOTE_F4, NOTE_F4, NOTE_DS4, NOTE_D4, NOTE_AS3
};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
6, 5, 6, 5, 1, 5 ,
6, 5, 6, 5, 1, 5 ,
6, 5, 6, 5, 4, 4 , 6, 5, 4
};
int buttonState = 0;         // variable for reading the pushbutton status
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);

}

void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
// turn LED on:
for (int thisNote = 0; thisNote < 25; thisNote++) {

// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000/noteDurations[thisNote];
tone(soundPin, melody[thisNote],noteDuration);

// to distinguish the notes, set a minimum time between them.
// the note’s duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.50;
delay(pauseBetweenNotes);
// stop the tone playing:
digitalWrite(ledPin, HIGH);
}
}else {
// turn LED off:
noTone(soundPin);
digitalWrite(ledPin, LOW);
}

}

Ultrasonic sensor (HC – SR04) and Piezo speakers measuring distance and playing a tone with Piezo

Last time I tested out a sensor, Joystick. This week I was given a HC – SR04 Ultrasonic sensor to test it out.

This sensor is best described as in its datasheet found here.The most essential part is this:

(3) IF the signal back, through high level , time o
f high output IO duration is
the time from sending ultrasonic to returning.
Test distance = (high level time×velocity of sound
(340M/S) / 2,

So we send a short pulse to trig pin to send of the sound. Then IF  it bounces back, the distance is the time of high output with conjuction with the above formula.

Requirements

  • Arduino
  • 2 LED
  • 1 HC-SR04
  • 1 resistor
  • jump cables

Sketch

Screenshot - 02092014 - 12:16:42 PM
Images made with Fritzing.
Screenshot - 02092014 - 12:16:19 PM
Images made with Fritzing.

http://fritzing.org/home/

I modified code from http://arduinobasics.blogspot.com.au/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html and added things of my own. There are 2 leds on the board, and a piezo speaker. When HC-SR04 doesn’t pick anything up or is out of range, yellow led is on. When the sensor gets back a signal, Yellow led is turned off and another led is lit up to indicate target is in range of the sensor. This information is also printed to the serial monitor with

Serial.print(“Distance = ” );
Serial.print(distance);
Serial.println(” cm” );

Note println on last line. We want to print all the info on one line at a time. This is more readable on the serial monitor. If all the the lines would be Serial.println  the output would look like this

Distance =

10

cm

Distance =

15

cm

Instead of

Distance is = 10 cm

Distance is = 15 cm

Read more about Print here

In addition to leds turning off and off, I was given a speaker to test out with. These 3 pages from arduino.cc helped me a TON to understand tone:

http://arduino.cc/en/Reference/tone

http://arduino.cc/en/Tutorial/Tone

http://arduino.cc/en/Tutorial/Tone4

Lets look at the code below:

tone(soundPin, 800, 300);
delay(distance); // Distance is the delay in ms between tones, ie Near maxRange -> Long tones, Near minimumRange -> Rapid tones.
noTone(soundPin);

As you know after reading the 3 above links Tone syntax is tone(pin, frequency, duration). So in this code I play a tone in soundPin, defines as 12 in setup, freq 800 for 300ms. After this we delay the sound by the distance. Delay is in ms and our distance is in cm. The noTone is not necessarily needed, as we define the length of the sound earlier. I wanted to make sure it turns off though, so I added this for my the safety of my ears.

IDEA

The delay could have been distance*x because a bleeping tone reading a 1cm would be kinda annoying playing every 1ms + 50ms (endoftheloop delay).

The whole code is commented below, ask me question in the comments if I left anything unanswered.

/*
HC-SR04 Ping distance sensor:
VCC to arduino 5v
GND to arduino GND
Echo to Arduino pin 7
Trig to Arduino pin 8
This sketch originates from Virtualmix: http://goo.gl/kJ8Gl
Has been modified by Winkle ink here: http://winkleink.blogspot.com.au/2012/05/arduino-hc-sr04-ultrasonic-distance.html
And modified further by ScottC here: http://arduinobasics.blogspot.com.au/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html
on 10 Nov 2012
Further modified by Peter Takacs on 04/02/04 https://patakacs.wordpress.com/2014/02/04/ultrasonic-sensor-hc-sr04-and-piezo-speakers-measuring-distance-and-playing-a-tone-with-piezo/
*/

int echoPin =  7;
int trigPin =  8;
int LEDPinYellow = 2; // Yellow LED
int LEDPinGreen = 4; // Green LED
int soundPin = 12; // Piezo

int maximumRange = 100;
int minimumRange = 0;
long duration, distance;

void setup() {
Serial.begin (9600); // Init communications to serial monitor
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LEDPinYellow, OUTPUT);
pinMode(LEDPinGreen, OUTPUT);
}

void loop() {
/* The following trigPin/echoPin cycle is used to determine the
distance of the nearest object by bouncing soundwaves off of it. */
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

digitalWrite(trigPin, HIGH);
delayMicroseconds(10);

digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);

//Calculate the distance (in cm) based on the speed of sound.
distance = duration/58.2;

if (distance >= maximumRange || distance <= minimumRange){
// Yellow led indicated out of maximumRange. Prints “Out Of Range” to serial if target is outside maximumRange.
Serial.println(“Out Of Range”);
digitalWrite(LEDPinYellow, HIGH);
digitalWrite(LEDPinGreen, LOW);
}
else {
// When ultasonic sensor picks up a signal _within_ maximumRange, print distance in cm to serial monitor, turn off YellowLed and turn on GreenLED.
Serial.print(“Distance = ” );
Serial.print(distance);
Serial.println(” cm” );
digitalWrite(LEDPinYellow, LOW);
digitalWrite(LEDPinGreen, HIGH);
tone(soundPin, 800, 300);
delay(distance); // Distance is the delay in ms between tones, ie Near maxRange -> Long tones, Near minimumRange -> Rapid tones.
noTone(soundPin);

}

// Mandatory delay
delay(50);
}

Sources:

Tero Karvinen’s lessons in Haaga-Helia University of Applied Sciences

NOTE: All images (if any) used on this post were self-taken. Fritzing photos are made with Fritzing and is the property of Fritzing.

“This document can be copied and modified under the conditions of GNU General Public License. http://www.gnu.org/licenses/gpl.html