Hypnotizing Wheel Complete Project

Hypnotizing Wheel Complete Project

 

Spinning wheels were popular back in the 20th century, they were used to “hypnotize patients” or help them enter trance. Nowadays they are seen more as a retro novelty than a hypnotizing tool. Cool optical illusions, like objects enlarging and shrinking can still be obtained by using one.

In this tutorial we will show you how to build a spinning hypnotizing wheel using Jaycon’s Pro Nano to build it. This is a small but powerful microcontroller with programmable PWM, analog and digital pins. The Pro Nano will be reading a signal sent by a force sensor that we will use to control the PWM (Pulse Width Modulation) signal. We will use that signal to adjust the speed of a motor (spinning wheel)  and also the intensity of two LEDs.   

Ready to go retro ?

Pro Nano

Jaycon’s Pro Nano Microcontroller

Jaycon’s Pro Nano Microcontroller

 

Jaycon’s Pro Nano is an Arduino compatible microcontroller development board based on the ATtiny85 microcontroller. It is based around the DigiSpark which uses the micronucleus bootloader.

The board is broken down into 10 individual pins and has 2 internal LEDs in which one is dedicated to power indication. It has 5 GPIO pins and two are shared with the USB interface. Two of these pins are capable of PWM and other 3 can be used as Analog Pins by programming them. You will be able to see it more clearly with the diagrams and table below.

AtTiny 85 Pinning #1

AtTiny 85 Pinning #1

 

AtTiny 85 Pinning #2

AtTiny 85 pinning #2

 

Pin declaration #

AtTiny 85

Jaycon's Pro Nano

-

-

VCC

0 (PWM)

PB0

B0

1 (PWM)

PB1

B1

2    /   A1

PB2

B2

-

GND

GND

-

-

5V

-

-

RAW

RESET

PB5

B5

4    /   A2

PB4

D+

3    /   A3

PB3

D-

 

This version runs on 5.0V and has an onboard voltage regulator so you can also run on a 12V supplied to the "RAW" pin.

To use the pins as analog or digital you have to state which mode you want when declaring the appropriate pins in the code. Refer to the table above for declaration values.

Now that we know the basics of our Pro Nano board, let's start making our hypnotizing wheel.

 

Materials for Hypnotizing Wheel Project

Materials for Hypnotizing Wheel Project

 

Hardware

Jaycon’s Pro Nano (or any other microcontroller)

1 x Force Sensing Resistor

1 x Small Motor

1 x 270 Ω resistor

1 x 220 Ω resistor

1 x 10k Ω resistor

1 x 1A diode

1 x NPN Transistor

2 x red LEDs

Breadboard & wires

Wiring and connections

Hypnotizing Wheel Schematic

Hypnotizing Wheel Schematic

Please be aware that the force sensor is in the circuit as the Varistor, I used the variable resistor symbol  because that is exactly what the force sensor is, a resistor which value will vary depending on the force applied on the pad.

.

Hypnotizing Wheel Circuit Diagram

Hypnotizing Wheel Circuit Diagram

 

First we are going to start with the force sensor, I am using an Interlink Electronics force sensing resistor with 0.2” of diameter. I connected this sensor to D+ and I am using this pin as an Analog Input so it has to be declared as “A2”. For this connection I am also using a 10k Ω resistor as a pull-down resistor to prevent floating.

With this connection I will be able to get an analog reading to control the motor speed and the LED intensity.

 

Force Sensor

Force Sensor

 

The motor is next, I am going to be using pin B0 to output the PWM signal for the motor, but this won't be going directly into it. I have to place a transistor between the motor and the microcontroller. I picked an NPN transistor, to be specific, I used a 2N3904 general purpose transistor, you don’t need to use this exact one, just make sure that the specs are similar, there are many different transistors out there.

My collector will be connected to one leg of the motor, in that same node connect a rectifier diode to prevent current backflow that could be generated by the motor, also run a wire to the 5V line.  The base will be connected with a 270 Ω resistor to the microcontroller, in my board I have B1 setup as an output pin . Finally connect  the emitter to ground. If you are still confused about the wiring, follow the diagram and you should be good.

Note: My computer outputs 0.5 A trough the USB connection, a 270 Ω resistor is enough for my transistor’s base to act as a switch, if you are providing more current you might have to vary the resistor value for the transistor to work.

The project will work as it is, but I decided to add some LED lights just for effect purposes, I placed them in parallel so they share not only ground but also a 220 Ω resistor that connects to the 5V line.

 

Hypnotizing Wheel Complete Project

Hypnotizing wheel completed project

 

Now everything should be ready to power up, but first we have to program the microcontroller.  

Programming

Like stated before, I am not using a conventional Arduino Board, instead I am using a Pro Nano with a Digispark ATtiny85 with a bootloader, with this we are still able to use the Arduino IDE to program the board.  

This tutorial by Digistump will guide you through the necessary steps to be able to use the Arduino IDE. Once you have all set up come back here and we will continue.

https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/attiny85-use-hints

Now that you have all set up be aware of something, every time you want to upload a code to the microcontroller you have to physically disconnect the cable, press the upload button, wait for the screen to tell you to plug the device and then do it. Within a few seconds you should have your code uploaded.

Go to Tools > Board and make sure you have selected Default - 16.5 mhz

Now it's time to enter the code: You can copy the code I've developed below (feel free to play with and edit this code). If you prefer, go ahead and enter your own code. We acknowledge that there are several ways to achieve results with this project. If you have any suggestions or ideas please let us know in the comment section.

//www.jayconsystems.com

int sensorPin = A2;    //This is the Pin for the Force sensor

int sensorValue =0; //variable to store the value coming from the sensor

int speedval1 =0;  //speed for the motor
int speedval2 = 0; // speed for the LED

int LedPin = 1;   //PWM pin for the LEDS
int motorPin = 0; //PWM pin for the motor

void setup() {
 
 pinMode(sensorPin, INPUT); // declare the sensor Pin as an INPUT:
 pinMode(motorPin, OUTPUT); // declare the motor Pin as an OUTPUT:
  pinMode(LedPin, OUTPUT); // declare the Led Pin as an OUTPUT:
  
 Serial.begin(9600);          //  setup serial communication
}

void loop() {
 // read the value from the sensor:
 sensorValue = analogRead(sensorPin);

 //declare the value of the speed for both LED & Motor
 
 speedval1 = sensorValue/24; //motor speed scaled 1/24 to slow down the spinning speed
 speedval2 = sensorValue;    // the PWM value is not scaled down to have full brightness in the LED's
 
 analogWrite(motorPin, speedval1); // output scaled PWM for motor
 analogWrite(LedPin, speedval2);  // output scaled PWM for LED 

//www.jayconsystems.com