The Leostick is an Arduino Leonardo compatible board from Freetronics.
This all means that you can actually have quite a lot of fun with the Leostick straight out of its anti-static bag. However, the fun does not end there. Oh no, there is even more. The Leostick comes with a set of header pins and yes, they also sell little mini proto-shields that you can fit onto the Leostick.
Mini Project
To try out the Leostick, I decided to have a go at a little project from the second edition of my book '30 Arduino Projects for the Evil Genius' - out May 2013. This project was originally designed for an Arduino Leonardo.
It has two buttons, and when you press one it generates an obscure password and stores it in EEPROM. When you press the other button, it emulates a keyboard and types the password for you, wherever your password happens to be.
This proved to be really easy to do. Here is the finished result on a Leoshield.
Step 1.
Solder the header sockets onto the Leostick and the header pins onto the Leoshield.
It is easier to solder the header pins onto the shield if you first push them into the sockets on the Leostick.
Step 2.
Solder the click switches and wires.
Make sure you get the switches the right way around. Look carefully at the diagram above. One way around there will be two unused holes between pins (left to right) the other way (vertically) there will be just one.
The bare wire at the bottom connects GND to one side of both switches. The other sides of the switches are connected to D7 and D6.
Here is the sketch, ignore the bit of paper that comes with the Leostick saying you need to download something, you don't, just use it like you would an Arduino Leonardo.
#include <EEPROM.h>
int greenPin = 9;
int soundPin = 11;
int typeButton = 7;
int generateButton = 6;
int passwordLength = 10;
char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
void setup()
{
pinMode(greenPin, OUTPUT);
pinMode(soundPin, OUTPUT);
pinMode(typeButton, INPUT_PULLUP);
pinMode(generateButton, INPUT_PULLUP);
Keyboard.begin();
}
void loop()
{
if (digitalRead(typeButton) == LOW)
{
notify(1);
typePassword();
}
if (digitalRead(generateButton) == LOW)
{
notify(3);
generatePassword();
}
delay(300);
}
void typePassword()
{
for (int i = 0; i < passwordLength; i++)
{
Keyboard.write(EEPROM.read(i));
}
Keyboard.write('\n');
}
void generatePassword()
{
randomSeed(millis() * analogRead(A0));
for (int i = 0; i < passwordLength; i++)
{
EEPROM.write(i, randomLetter());
}
}
char randomLetter()
{
int n = strlen(letters);
int i = random(n);
return letters[i];
}
void notify(int n)
{
for (int i = 0; i < n; i++)
{
tone(soundPin, 330);
digitalWrite(greenPin, HIGH);
delay(200);
noTone(soundPin);
digitalWrite(greenPin, LOW);
delay(200);
}
}
For good measure the sketch uses both the built-in RGB LED and the buzzer to provide feedback when you press a button.
To test it, just put your cursor in a blank document in an editor or wordprocessor. Pressing the button furthest away from the USB plug will generate a new password and beep three times, while flashing the LED green.
Pressing the other button will write out the password. So, now you can carry this everywhere with you and use it to type your passwords for you.
Summary
Pros
Cons
There are a number of things that make this board a great deal more than a clone:
- Its smaller than the Uno / Loenardo sized Arduinos. In fact about the size of a USB flash drive.
- It has a USB plug built onto the PCB, so you can plug it straight into the side of your computer to program it. Or use an USB extension lead.
- It has a built-in RGB LED.
- Being a Leonardo type board means that you can have it emulate a keyboard and mouse!
- Flip it over and it has a piezo sounder on the back.
This all means that you can actually have quite a lot of fun with the Leostick straight out of its anti-static bag. However, the fun does not end there. Oh no, there is even more. The Leostick comes with a set of header pins and yes, they also sell little mini proto-shields that you can fit onto the Leostick.
Mini Project
To try out the Leostick, I decided to have a go at a little project from the second edition of my book '30 Arduino Projects for the Evil Genius' - out May 2013. This project was originally designed for an Arduino Leonardo.
It has two buttons, and when you press one it generates an obscure password and stores it in EEPROM. When you press the other button, it emulates a keyboard and types the password for you, wherever your password happens to be.
This proved to be really easy to do. Here is the finished result on a Leoshield.
Step 1.
Solder the header sockets onto the Leostick and the header pins onto the Leoshield.
It is easier to solder the header pins onto the shield if you first push them into the sockets on the Leostick.
Step 2.
Solder the click switches and wires.
Make sure you get the switches the right way around. Look carefully at the diagram above. One way around there will be two unused holes between pins (left to right) the other way (vertically) there will be just one.
The bare wire at the bottom connects GND to one side of both switches. The other sides of the switches are connected to D7 and D6.
Here is the sketch, ignore the bit of paper that comes with the Leostick saying you need to download something, you don't, just use it like you would an Arduino Leonardo.
#include <EEPROM.h>
int greenPin = 9;
int soundPin = 11;
int typeButton = 7;
int generateButton = 6;
int passwordLength = 10;
char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
void setup()
{
pinMode(greenPin, OUTPUT);
pinMode(soundPin, OUTPUT);
pinMode(typeButton, INPUT_PULLUP);
pinMode(generateButton, INPUT_PULLUP);
Keyboard.begin();
}
void loop()
{
if (digitalRead(typeButton) == LOW)
{
notify(1);
typePassword();
}
if (digitalRead(generateButton) == LOW)
{
notify(3);
generatePassword();
}
delay(300);
}
void typePassword()
{
for (int i = 0; i < passwordLength; i++)
{
Keyboard.write(EEPROM.read(i));
}
Keyboard.write('\n');
}
void generatePassword()
{
randomSeed(millis() * analogRead(A0));
for (int i = 0; i < passwordLength; i++)
{
EEPROM.write(i, randomLetter());
}
}
char randomLetter()
{
int n = strlen(letters);
int i = random(n);
return letters[i];
}
void notify(int n)
{
for (int i = 0; i < n; i++)
{
tone(soundPin, 330);
digitalWrite(greenPin, HIGH);
delay(200);
noTone(soundPin);
digitalWrite(greenPin, LOW);
delay(200);
}
}
For good measure the sketch uses both the built-in RGB LED and the buzzer to provide feedback when you press a button.
To test it, just put your cursor in a blank document in an editor or wordprocessor. Pressing the button furthest away from the USB plug will generate a new password and beep three times, while flashing the LED green.
Pressing the other button will write out the password. So, now you can carry this everywhere with you and use it to type your passwords for you.
Summary
Pros
- What's not to like - see everything I have written so far
- Gold plated everything - Freetronics know how to make a good PCB
- Pin usage labelled on the board and a jumper to break if you don't want sound.
Cons
- A very minor, I2C SDA and SCL would be the icing on the cake. But probably not worth spoiling the pinout for.
2 comments:
I am looking to add 4 switches and set them up as four functions in a program do not have room for a keyboard can I use this usb interface
I am looking to use this with 4 switches and have them used as 4 flags in a program.
do not have room for a full keyboard
Do you think this will work
Post a Comment