Details:
An Arduino propeller display is a type of electronic display that uses a spinning propeller to display images or text. The propeller is mounted on a motor, and the Arduino microcontroller is used to control the speed and direction of the motor.
The display works by illuminating a row of LEDs as the propeller spins, creating the appearance of a solid image or text. By changing the speed and direction of the motor, different images or messages can be displayed.
To build an Arduino propeller display, you will need the following materials:
Arduino microcontroller board
Motor with propeller attached
LED strip
Power supply
Jumper wires
Breadboard or prototyping board
Resistors (if necessary)
Here are the steps to build the Arduino propeller display:
Connect the LED strip to the Arduino microcontroller using jumper wires. Make sure to connect the positive and negative leads correctly.
Connect the motor to the Arduino microcontroller using jumper wires. Again, make sure to connect the positive and negative leads correctly.
Upload the code for the propeller display to the Arduino microcontroller.
Connect the power supply to the LED strip and motor.
Test the display by running the code on the Arduino microcontroller.
Adjust the speed and direction of the motor as necessary to create the desired display.
There are many tutorials and resources available online for building Arduino propeller displays, so be sure to do some research before getting started.
Arduino code:
#include <BasicLinearAlgebra.h>
#include <DueFlashStorage.h>
#include <efc.h>
#include <flash_efc.h>
#include <Ultrasonic.h>
#include <Encoder.h>
//Pins gone 42,43,8,44,45,9, 22-29 , 30-33 , 2-7 ,40,41,46,47, A0-A7 , A8-A11 ,
#define kp 1
#define kd 1
#define ki 0
#define leap 30
#define delSpeed 300
#define kpw 1
#define kdw 1
#define kiw 0
#define leapw 30
#define delSpeedw 300
#define dt 10
#define turnError 3
long leftGo, rightGo, pl=100, pr=100;
#define leftMotorBaseSpeed 2000
#define rightMotorBaseSpeed 2000
#define maxSpeed 4095
#define disk1 0x50
#define leftMotor1 42
#define leftMotor2 43
#define leftMotorPWM 8
#define rightMotor1 44
#define rightMotor2 45
#define rightMotorPWM 9
#define maxDistance 40
#define widthOfWall 50
#define widthOfBot 15
#define widthOfWheel 15
#define limitF 40
#define limitR 30
#define limitL 30
#define shapeMem 10
#define prevShapeMem 11
#define ShapesMem0 20
#define ShapesMem1 21
#define ShapesMem2 22
#define errorMem0 30
#define errorMem1 31
#define errorMem2 32
#define turnMem 40
#define dirMem1 50
#define dirMem2 51
#define checkPointMem 60
#define turnMemArrayPin 100
#define finalTurnMemArrayPin 400
#define ledPin 22
#define startPin 30
#define cavePin 31
#define bridgePin 32
#define boxPin 33
#define mazePin 34
int leftMotorEnc1 = 47;
int leftMotorEnc2 = 46;
int rightMotorEnc1 = 40;
int rightMotorEnc2 = 41;
Ultrasonic ultrasonicLeft(2, 3);
Ultrasonic ultrasonicFront(4, 5);
Ultrasonic ultrasonicRight(6, 7);
long leftDistance, frontDistance, rightDistance;
Encoder leftEnc(47, 46);
Encoder rightEnc(40, 41);
DueFlashStorage Flash;
long pulsePerTurn = 48;
long distancePerTurn=13.2;
long degree = 0;
long leftPulse = 0;
long rightPulse = 0;
long startLeftPulse = 0;
long startRightPulse = 0;
long lasttLeftPulse = 0;
long lasttRightPulse = 0;
long posRead, prevPosRead, linePos, Error=0, pastError=0, proportional=0, derivative=0, integral=0, pid=0;
long posReadw, prevPosReadw, linePosw, Errorw=0, pastErrorw=0, proportionalw=0, derivativew=0, integralw=0, pidw=0;
long linePositions[3] = {0, 0, 0};
int i, j, k=0, n, nd[3]={0,0,0}, l, mt,ft;
char prevShape = '0', shape = '0', shapes[3]={'0','0','0'}, cavePresent = 'y', bridgePresent = 'n', boxPresent = 'y', dir1 = '0', dir2 = '0', turnPos='F';
char prior = 'r', checkPoint='p', turnMemArray[300]={NULL}, FinalurnMemArray[100]={NULL};
byte shapeData, prevShapeData;
int irValue[8] = {0, 0, 0, 0, 0, 0, 0, 0}, irThershold = 2000;
int calculationDone=0, fri=0;
void setup() {
Serial.begin(9600);
analogWriteResolution(12);
pin();
delay(2000);
}
void checkTurn(){
for(i=0; i<5; i++){
turnRight();
delay(2000);
}
}
void pin() {
pinMode(leftMotor1, OUTPUT);
pinMode(leftMotor2, OUTPUT);
pinMode(rightMotor1, OUTPUT);
pinMode(rightMotor2, OUTPUT);
pinMode(leftMotorPWM, OUTPUT);
pinMode(rightMotorPWM, OUTPUT);
for (i = 0; i < 12; i++) {
pinMode(A0 + i, INPUT);
}
for (i = 0; i < 4; i++) {
pinMode(30 + i, INPUT);
}
for (i = 0; i < 8; i++) {
pinMode(ledPin + i, OUTPUT);
digitalWrite(ledPin + i, HIGH);
delay(50);
}
delay(200);
for (i = 0; i < 8; i++) {
digitalWrite(ledPin + i, LOW);
delay(50);
}
}
void loop() {
if(digitalRead(mazePin) == 1){
finalRun();
}
else{
pos();
shape=shapeRead();
if(shape=='F'){
follow();
}
else{
turnPos=delPos();
if(turnPos=='T'){
if(prior=='l'){
turnLeft();
}
else{
turnRight();
}
}
if(turnPos=='R'){
turnRight();
}
if(turnPos=='L'){
turnLeft();
}
if(turnPos=='<'){
turnLeftBack();
}
if(turnPos=='>'){
turnRightBack();
}
if(turnPos=='B'){
}
}
}
}
void finalRun(){
pos();
shape=shapeRead();
if(shape=='F'){
follow();
}
else{
turnPos=delPos();
if(turnPos=='R'){
turnRight();
}
if(turnPos=='L'){
turnLeft();
}
if(turnPos=='T'){
if(readCheckPoint(FinalurnMemArray[fri]=='S')){
turnStraight();
fri++;
}
if(readCheckPoint(FinalurnMemArray[fri]=='L')){
turnLeft();
fri++;
}
else{
turnRight();
fri++;
}
}
if(turnPos=='<'){
if(readCheckPoint(FinalurnMemArray[fri]=='S')){
turnStraight();
fri++;
}
if(readCheckPoint(FinalurnMemArray[fri]=='L')){
turnLeft();
fri++;
}
else{
turnRight();
fri++;
}
}
if(turnPos=='>'){
if(readCheckPoint(FinalurnMemArray[fri]=='S')){
turnStraight();
fri++;
}
if(readCheckPoint(FinalurnMemArray[fri]=='L')){
turnLeft();
fri++;
}
else{
turnRight();
fri++;
}
}
if(turnPos=='B'){
}
}
}
void irRead() {
n = 0;
for (i = 0; i < 8; i++) {
irValue[i] = analogRead(A0 + i);
printI(irValue[i]);
if (irValue[i] >= irThershold) {
irValue[i] = 1;
n++;
}
else {
irValue[i] = 0;
}
printI(irValue[i]);
}
}
long pos() {
posRead = 0;
irRead();
for (i = 0; i < 8; i++) {
posRead = (irValue[i] * i * 100) + posRead;
}
if (n == 0) {
return 0;
}
else {
posRead = posRead / n;
printL(posRead);
posRead = posRead - 350;
return posRead;
}
}
char delPos() {
if(shape=='L'){
for (i = 0; i < 3; i++) {
setMotor(delSpeed, delSpeed);
delay(leap * .5);
linePositions[i] = pos();
shapes[i]=shapeRead();
nd[i]=n;
}
if(shapes[2]=='W' || prior=='l'){
return 'L';
}
else{
return '<';
}
}
else if(shape=='R'){
for (i = 0; i < 3; i++) {
setMotor(delSpeed, delSpeed);
delay(leap * .5);
linePositions[i] = pos();
shapes[i]=shapeRead();
nd[i]=n;
}
if(shapes[2]=='W' || prior=='r'){
return 'R';
}
else{
return '>';
}
}
else if(n==0){
for (i = 0; i < 3; i++) {
setMotor(delSpeed, delSpeed);
delay(leap * .5);
linePositions[i] = pos();
nd[i]=n;
}
if (linePositions[0] == 0 && linePositions[1] == 0 && linePositions[2] == 0) {
return 'U';
}
else{
return 'F';
}
}
else if(n==8){
for (i = 0; i < 3; i++) {
setMotor(delSpeed, delSpeed);
delay(leap * .5);
linePositions[i] = pos();
nd[i]=n;
}
if(nd[0]==8 && nd[1]==8 && nd[2]==8) {
delay(leap * .5);
return 'B';
}
if(nd[2]==0){
return 'T';
}
else{
return '+';
}
}
}
char shapeRead(){
if(n==8){
return 'T';
}
if(n==0){
return 'W';
}
if((irValue[0]==1 && irValue[1]==1 && irValue[2]==1 && irValue[3]==1) && (irValue[7]==0 && irValue[6]==0)){
return 'L' ;
}
if((irValue[7]==1 && irValue[6]==1 && irValue[5]==1 && irValue[4]==1) && (irValue[0]==0 && irValue[1]==0)){
return 'R' ;
}
else{
return 'F';
}
}
char writeCheckPoint(int mem, char c){
shapeData=(byte)c;
Flash.write(mem,shapeData);
}
char readCheckPoint(int mem){
byte valB=Flash.read(mem);
char valC=(char)valB;
return valC;
}
long Pid(){
Error=posRead;
proportional=Error;
derivative=Error-pastError;
integral=Error+pastError;
if(integral<=-2000){
integral= (-2000);
}
if(integral>=2000){
integral= (2000);
}
pastError=Error;
pid=proportional*kp+integral*ki+derivative*kd;
return pid;
}
void follow() {
pid=Pid();
signed int motorLspeed=(signed int)(leftMotorBaseSpeed+pid);
signed int motorRspeed=(signed int)(rightMotorBaseSpeed-pid);
setMotor(motorLspeed, motorRspeed);
}
void followPrior(){
if(prior=='l'){
turnLeft();
}
else{
turnRight();
}
}
void followRevPrior(){
if(prior=='r'){
turnLeft();
}
else{
turnRight();
}
}
void turnRight() {
Flash.write(turnMem,'R');
}
void turnRightBack() {
Flash.write(turnMem,'>');
if(prior=='r'){
turnRight();
}
else{
turnStraight();
}
}
void turnLeft() {
Flash.write(turnMem,'L');
}
void turnLeftBack() {
Flash.write(turnMem,'<');
if(prior=='l'){
turnLeft();
}
else{
turnStraight();
}
}
void turnReverse() {
turnRight();
turnRight();
Flash.write(turnMem,'U');
}
void turnStraight(){
}
void brake(){
digitalWrite(leftMotor1, HIGH);
digitalWrite(leftMotor2, HIGH);
digitalWrite(leftMotorPWM, HIGH);
digitalWrite(rightMotor1, HIGH);
digitalWrite(rightMotor2, HIGH);
digitalWrite(rightMotorPWM, HIGH);
}
void back(){
setMotor(-delSpeed, -delSpeed);
delay(leap * 4);
}
void finish(){
brake();
delay(1000);
calculatePath();
}
void setMotor(signed int motor1speed, signed int motor2speed){
if (motor1speed > maxSpeed )
{
motor1speed = maxSpeed;
}
if (motor2speed > maxSpeed )
{
motor2speed = maxSpeed;
}
if (motor1speed < (-maxSpeed) )
{
motor1speed = -maxSpeed;
}
if (motor2speed < (-maxSpeed) )
{
motor2speed = -maxSpeed;
}
if (motor1speed >= 0 && motor2speed >= 0)
{
digitalWrite(leftMotor1, HIGH);
digitalWrite(leftMotor2, LOW);
analogWrite(leftMotorPWM, abs(motor1speed));
digitalWrite(rightMotor1, HIGH);
digitalWrite(rightMotor2, LOW);
analogWrite(rightMotorPWM, abs(motor2speed));
}
if (motor1speed < 0 && motor2speed < 0)
{
digitalWrite(leftMotor1, LOW);
digitalWrite(leftMotor2, HIGH);
analogWrite(leftMotorPWM, abs(motor1speed));
digitalWrite(rightMotor1, LOW);
digitalWrite(rightMotor2, HIGH);
analogWrite(rightMotorPWM, abs(motor2speed));
}
if (motor1speed >= 0 && motor2speed < 0)
{
digitalWrite(leftMotor1, HIGH);
digitalWrite(leftMotor2, LOW);
analogWrite(leftMotorPWM, abs(motor1speed));
digitalWrite(rightMotor1, LOW);
digitalWrite(rightMotor2, HIGH);
analogWrite(rightMotorPWM, abs(motor2speed));
}
if (motor1speed < 0 && motor2speed >= 0)
{
digitalWrite(leftMotor1, LOW);
digitalWrite(leftMotor2, HIGH);
analogWrite(leftMotorPWM, abs(motor1speed));
digitalWrite(rightMotor1, HIGH);
digitalWrite(rightMotor2, LOW);
analogWrite(rightMotorPWM, abs(motor2speed));
}
}
long Turn(long leftGo, long rightGo){
k=0;
long leftPulseRequire=leftGo/distancePerTurn;
long rightPulseRequire=rightGo/distancePerTurn;
long leftPulseError, rightPulseError, leftPulse,rightPulse;
startLeftPulse=leftEnc.read();
startRightPulse=rightEnc.read();
leftPulseRequire=leftPulseRequire+startLeftPulse;
rightPulseRequire=rightPulseRequire+startRightPulse;
for(i=0; k!=100; i++){
leftPulse=leftEnc.read();
leftPulseError=(leftPulseRequire-leftPulse);
rightPulse=rightEnc.read();
rightPulseError=(rightPulseRequire-rightPulse);
leftPulseError=leftPulseError*pl; if(leftPulseError>=4000){ leftPulseError=4000;} if(leftPulseError<=(-4000)){ leftPulseError=(-4000);}
rightPulseError=rightPulseError*pr; if(rightPulseError>=4000){ rightPulseError=4000;} if(rightPulseError<=(-4000)){ rightPulseError=(-4000);}
setMotor((signed int)(leftPulseError), (signed int)(rightPulseError));
delay(dt);
if((abs(leftPulseError)<=turnError) && (abs(rightPulseError)<=turnError)){
brake();
delay(100);
k=100;
}
else{
setMotor(0,0);
delay(dt);
k=0;
}
}
}
void printI(int val) {
Serial.print(" ");
Serial.print(val);
Serial.print(" ");
}
void printC(char val) {
Serial.print(" ");
Serial.print(val);
Serial.print(" ");
}
void printF(float val) {
Serial.print(" ");
Serial.print(val);
Serial.print(" ");
}
void printL(long val) {
Serial.print(" ");
Serial.print(val);
Serial.print(" ");
}
void printS(signed int val) {
Serial.print(" ");
Serial.print(val);
Serial.print(" ");
}
void calculatePath(){
char calmem[300];
for(i=0; calculationDone!=1; i++){
k=0;
int cd=0;
for(j=0; j<mt; j++){
calmem[k]=readCheckPoint(turnMemArrayPin+j);
if(readCheckPoint(turnMemArrayPin+j)=='R' && readCheckPoint(turnMemArrayPin+j+1)=='U' && readCheckPoint(turnMemArrayPin+j+2)=='R'){
calmem[k]='S';
calculationDone=0;
cd++;
}
else if(readCheckPoint(turnMemArrayPin+j)=='S' && readCheckPoint(turnMemArrayPin+j+1)=='U' && readCheckPoint(turnMemArrayPin+j+2)=='U')
{
calmem[k]='U';
calculationDone=0;
cd++;
}
}
n=k;
if(cd==0){
calculationDone=1;
}
else{
mt=0;
for(l=0; l<n; l++){
writeCheckPoint(turnMemArrayPin+l, calmem[l]);
}
}
}
Comments
Post a Comment