Development Step #5 – Controlling servos using the face position.
o Approach.
o Learning Experience.
I used the Arduino Knob example as a basis for my code.
I changed the functionality of the code below from using a pot meter, to using data from Processing on x and y axis.
/*
Controlling a servo position using a potentiometer (variable resistor)
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
modified on 8 Nov 2013
by Scott Fitzgerald
hp://www.arduino.cc/en/Tutorial/Knob
/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
o Result.
Arduino Code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Servo.h> | |
Servo servoY; // create servo object to control a servo | |
Servo servoX; | |
int ValX; | |
int ValY; | |
byte Processing; | |
int val; // variable to read the value from the analog pin | |
void setup() { | |
ValY = 0; | |
ValX = 0; | |
Serial.begin(9600); | |
servoX.attach(13); // attaches the servo on pin 9 to the servo object | |
servoY.attach(12); | |
} | |
void loop() { | |
if (Serial.available() > 0) { | |
Processing = Serial.read(); | |
} | |
if (Processing == 'a') { | |
ValY–; | |
servoY.write(ValY); | |
} | |
if (Processing == 'b') { | |
ValY++; | |
servoY.write(ValY); | |
} | |
if (Processing == 'c') { | |
ValX–; | |
servoX.write(ValX); | |
} | |
if (Processing == 'd') { | |
ValX++; | |
servoX.write(ValX); | |
} | |
if (Processing == 'e') { | |
} | |
if (ValX >= 210){ | |
ValX = 210; | |
} | |
if (ValX <= 0){ | |
ValX = 0; | |
} | |
if (ValY >= 210){ | |
ValY = 210; | |
} | |
if (ValY <= 0){ | |
ValY = 0; | |
} | |
} |
Processing Code: https://gist.github.com/TheVisualG/f531f6f5845106767e749d81085954aa
The servos were not having a set diapason and they broke the wooden parts.
o Sources.
Arduino library examples
Development Step #6 – Installing Raspbian and VNC
o Approach.
I am going to follow the steps mentioned on the official website for the installation of the Raspbian OS.
What I need:
– Raspberry
– Power / micro-USB cable + power supply out-putting more than 1A
– USB splitter
– Mouse
– Keyboard
– Monitor
VNC is a lightweight version of TeamViewer , it basically give you an easy access to a remote device. I will follow a guide on the official website.
o Learning Experience.
• First we download a ZIP file from this page https://www.raspberrypi.org/downloads/raspbian/
• We unzip the archive and take the ISO file
• Then using a software called Etcher we Install the ISO file hps://etcher.io/ on the SD card.
• If all goes well we can plug the power cable, the hdmi cable, the keyboard and the mouse and boot into Raspbian.
• Opening terminal.
• The next step is updating the OS to the latest release by typing:
sudo apt-get update
sudo apt-get upgrade
sudo reboot
https://learn.pimoroni.com/tutorial/raspberry-pi/keeping-your-raspberry-pi-updated
• If you prefer you can also update the karnel itself by typing:
sudo rpi-update
VNC
https://www.raspberrypi.org/documentaon/remote-access/vnc/
• first install the viewer on your laptop/PC https://www.realvnc.com/en/connect/download/viewer/
• After that download VNC on the raspberry
• After that install in your router settings assign make the raspberry connection Static and then ping it and find
out what is the IP address https://www.raspberrypi.org/documentaon/remote-access/ip-address.md
o Result.
I followed the steps but at first my raspberry was not boong anything from the SD card.
I tried another approach, which I found while googling my issue.
Instead of using Etcher, I used a software called SD Memory Card Formatter to format the SD card and after that Win32DiskImager
https://www.raspberrypi.org/documentation/installation/installing-images/windows.md
It did work out and I booted into the OS, after updating it through the RPI-update function it stuck on that screen while booting:
After redoing the whole process several times I finally found the issue:
Not every SD card is compatible and I ended using:
On raspberry zero:
On respberry pi 3b:
And I don’t recommend updating the karnel.
I followed the instructions for VLC and it is working!
o Sources
https://www.raspberrypi.org/
https://learn.pimoroni.com/tutorial/raspberry-pi/keeping-your-raspberry-pi-updated
https://www.raspberrypi.org/documentation/installation/installing-images/windows.md
https://sourceforge.net/projects/win32diskimager/files/latest/download
https://www.balena.io/etcher/
https://www.sdcard.org/downloads/formatter_4/
https://www.raspberrypi.org/documentation/remote-access/ip-address.md
https://www.realvnc.com/en/connect/download/viewer/
https://www.raspberrypi.org/documentation/remote-access/vnc/