This is a simple project that allows you to create a circuit which will give a visual indication if the breadboard has been tilted. In the upright position, the Green LED is illuminated. To the left of the board is a tilt switch. If the project is tilted, the switch will go from the closed to the open condition. This can be detected on the arduino, and then the red LED is illuminated. The video below explains how to do this simple project.
You can get the kit we are using in these lessons HERE. You should create your own code based on the instructions in the video, but if you are having trouble, I include the code developed in the video below:
In this lesson we show you how to install Visual Python (Vpython) and show you how to begin to build 3D visuals. We introduce you to some of the basic objects and how how control how they look and where they are.
In this lesson we give you several examples of how to connect and program a stepper motor. Stepper motors are useful because they can produce very large torque at low RPM and are capable of extremely precise positioning. They are somewhat tricky to use, and you must be careful to not try and power them from an Arduino. Arduino can control stepper motors, but they must be powered from an external power supply.
If you want to follow along at home, you can order the Arduino Kit we are using HERE.
This is the code that allows you to toggle the direction of the stepper motor by pressing a pushbutton. The video shows all the details and how to connect the motor up.
Arduino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <Stepper.h>
intstepsPerRevolution=2048;
intmotSpeed=3;
intdt=500;
intbuttonPin=2;
intmotDir=1;
intbuttonValNew;
intbuttonValOld=1;
SteppermyStepper(stepsPerRevolution,8,10,9,11);
voidsetup(){
// put your setup code here, to run once:
Serial.begin(9600);
myStepper.setSpeed(motSpeed);
pinMode(buttonPin,INPUT);
digitalWrite(buttonPin,HIGH);
}
voidloop(){
buttonValNew=digitalRead(buttonPin);
if(buttonValOld==1&&buttonValNew==0){
motDir=motDir*(-1);
}
myStepper.step(motDir*1);
buttonValOld=buttonValNew;
}
Making The World a Better Place One High Tech Project at a Time. Enjoy!