Tuesday, August 20, 2019

ATTiny85 Mouse

The ATTiny85 can not only act as a keyboard, it can also act as a mouse.
Extreme caution if you use this as the program does not only mouse movements, it also clicks!
( Examples \ DigisparkMouse \ Mouse )

// DigiMouse test and usage documentation
// CAUTION!!!! This does click things!!!!!!!!
// Originally created by Sean Murphy (duckythescientist)

#include <DigiMouse.h>

void setup() {
  DigiMouse.begin(); //start or reenumerate USB - BREAKING CHANGE from old versions that didn't require this
}

void loop() {
  // If not using plentiful DigiMouse.delay(), make sure to call
  // DigiMouse.update() at least every 50ms

  // move across the screen
  // these are signed chars
  DigiMouse.moveY(10); //down 10
  DigiMouse.delay(500);
  DigiMouse.moveX(20); //right 20
  DigiMouse.delay(500);
  DigiMouse.scroll(5);
  DigiMouse.delay(500);

  // or DigiMouse.move(X, Y, scroll) works

  // three buttons are the three LSBs of an unsigned char
  DigiMouse.setButtons(1<<0); //left click
  DigiMouse.delay(500);
  DigiMouse.setButtons(0); //unclick all
  DigiMouse.delay(500);

  //or you can use these functions to click
  DigiMouse.rightClick();
  DigiMouse.delay(500);
  DigiMouse.leftClick();
  DigiMouse.delay(500);
  DigiMouse.middleClick();
  DigiMouse.delay(500);

  //for compatability with other libraries you can also use DigiMouse.move(X, Y, scroll, buttons)
}

I have tested this script on with my digispark and it worked. The movements are relative to the current position. I did not dare to experiment and move it to bottom left on a windows computer and use Microsoft start to start programs.

Monday, August 19, 2019

ATTiny85 Keyboard

One of the scripts that works on my attiny85 is a keyboard emulator.
All is done  with the next simple script that was available as a sample script in the library;
(   File \ Examples \ DigisparkKeyboard \  Keyboard )

#include "DigiKeyboard.h"

void setup() {
  // don't need to set anything up to use DigiKeyboard
}

void loop() {
  // this is generally not necessary but with some older systems it seems to
  // prevent missing the first character after a delay:
  DigiKeyboard.sendKeyStroke(0);

  // Type out this string letter by letter on the computer (assumes US-style
  // keyboard)
  DigiKeyboard.println("Hello Digispark!");

  // It's better to use DigiKeyboard.delay() over the regular Arduino delay()
  // if doing keyboard stuff because it keeps talking to the computer to make
  // sure the computer knows the keyboard is alive and connected
  DigiKeyboard.delay(5000);
}


After uploading the script the program starts so watch out where to put the cursor when uploading the script.
The Digispark USB reacts if it is a keyboard where the  "Hello Digispark!" is typed over and over again (with a delay  5000 ).

Hello Digispark!
Hello Digispark!
Hello Digispark!
Hello Digispark!

An application could be reading some sensor data on the attiny85 and outputting it e.g. in a spreadsheet.

Saturday, August 17, 2019

ATTiny85 USB module prepared for experiments

Recently received some ATTiny85 USB (Digispark Digistump) boards from Aliexpress.
I already experimented earlier with these small boards with chip that can be programmed easy by putting it in the USB connector of your computer.
These boards come (standard) with Dupont connectors (male or female) that you can solder on these small boards to conello Digispark!
nect it easy in experiments. I wanted a not connecting each time Dupont wires, a little bit more protection for the USB module more distance from my computer,.
To prepare a module i cut some wires with female Dupont connectors and soldered this directly to the module. (To prevent shortcuts i used female not the male).
With transparent heat shrink i added some protection for the board.

ATTiny PINs

On the side (bottom of the picture) are three connections (starting from USB)
5V(Color of my wire: )  Red
GND      (Color of my wire: ) Black
Vin(Color of my wire: ) Brown
Opposite to the USB connector are 6 holes
Digital-AnalogPWMI2CPSIColor
of my
 wire
P0(LED on
 model B)
ArefPWM0SDAMQSIWhite
P1(LED on
 model A)

PWM1
MISOViolet
P2
A1
SCLSCKBlue
P3USB+A3

xxGreen
P4USB-A2PWM4
xxYellow
P5(Reset on
some models)
A0

xxOrange

A simple blink script to test the module is
// the setup routine runs once when you press reset:
void setup() { // initialize the digital pin as an output. 

//  pinMode(0, OUTPUT); //LED on Model B
     pinMode(1, OUTPUT); //LED on Model A or Pro }

// the loop routine runs over and over again forever:
void loop() {
//  digitalWrite(0, HIGH);   // turn the LED on (HIGH is the voltage level)
     digitalWrite(1, HIGH);
     delay(500);               // wait for a second


//  digitalWrite(0, LOW);    // turn the LED off by making the voltage LOW
     digitalWrite(1, LOW);
     delay(500);               // wait for a second
}


The led on my module reacts on P1. So I expect i have a model A.

Wednesday, August 14, 2019

SMD led breadboard friendly.

I wanted to do some easy prototyping with SMD leds (and other components).
SMD components are available in different (small) sizes.
One of the ways I made the SMD leds breadboard friendly is as follows:

1) Put an SMD led and a long Dupont pin connector on your workbench,
2) If the SMD led is somewhat bigger remove a pin (the second pin) from the connector.
3) Tin the Dupont connector where it needs to be connected to the led.
4) Push the Dupont connector on the led and solder by heating the connector. If needed add a little solder.
5) Cut the connector on the desired size (2 or '3' ) pin.
6) Test the led and the connections using a led tester.

By cutting the connector after soldering it is more easy to push the connector on the led and making the solder join.

On the picture you see at the left some end results and at the right a "standard" red led as size reference.
On the bottom left a " big" SMD led with a Dupont connector with the middle male pin removed.
The other 3 SMD leds are smaller leds that fit on two pins.

Tuesday, August 13, 2019

Flexible USB led light -1-

Making a custom flexible USB led

Building a flexible USB led.
It is possible to buy a cheap flexible led (or fan or other device) with an USB connector. It is more fun to build your own where you can use some special led's.  I created several different flexible USB devices. A fast flashing RGB led gives a nice effect.
The USB connector provides 5 Volts. After selecting a  led your own choice add a small resistor to limit the current. Shortened the legs of the led and added long red and black wires for power connection.
Led and resistor with red and black cable
 and  flexible hose.
With transparent heat shrink it is possible to isolate the wires and keep the resistor (value) readable.
A flexible oil hose (also available on Aliexpress) is used as a housing to make it flexible and stable at the same time. In this version i removed the connectors from the hose. It is also possible to change the hose length.
 For the power connector i used also some USB connectors from Aliexpress, an USB connector from an old cable can also be used.
USB
At the USB side of the hose cut away some of the plastic of the hose to make later a better connection. Take care to connect the + to plus and - to minus. By pushing wires and the led inside the hose you can cut the wires easy to the desired length.
After soldering i pushed in the USB connector back in the hose. With the correct wire length the led will just pop out of the other end of the hose. With hot glue the USB connector is glued to the hose.
USB connector and USB chassis part
 for testing and checking plus and minus.









Links to some Aliexpress items i bought (in 2019) to use in this project.

Fast RGB Flash leds
20 pcs 5mm Fast RGB Flash Red Green Blue Rainbow Multi Color light emitting diode Round Rainbow LED can change more than 7 color  (  € 0,89 for 20 pc)
Emitted Colour:RGB Rainbow Fast Flash
Rainbow LED can change more than 7 color
Size:5mm
long life 100000hrs (Voltage in the range of)
Energy saving and high efficiency
Super brightness
Operating temperature: -20 to 55°C
Storage temperature: -30 to 80°C
Forward Voltage(V):3-3.2V
Forward Current(mA):20
View Angle:About 25 degree
Luminous Intensity:Highlight
1 / 4W resistor corresponding voltage (For reference)
12V for 470 ohm/ 5V for 100 ohm/ 7.2v for 220 ohm / 9v for 330 ohm / 13.2v for 560 ohm

WSFS Hot 10PCS Round Nozzle 1/4PT Flexible Oil Coolant Pipe Hose Blue Orange For CNC Machine Lathe Milling Cooling Tube Retail    (  € 6,00 to € 7,00  for a lot with 10 pc)

10Pcs/Set DIY USB 2.0 Type A Male 4P Adapter Connector Plug Socket with Plastic Shell (10 pieces for 1,90 euro)