|
Home / projects / microcontrollers / Arduino ![]() Enclosure with Random Parts
![]() This is the enclosure with the button installed, the hole cut for the LED, and the perf board mounted. ![]() Inside view of the top panel so you can see the perf board mounted. I need to figure out some easy way to cut these, this time I just scored it with an xacto knife and then broke it off with pliers. As you can see that worked ok for the top layers and then left the rest rough. ![]() Another view, you can see the standoffs that the board is mounted too. ![]() The circuit for the 7 segment display. I can't find a shift register anywhere local so I have to order one. Once I have one that should reduce the number of pins used on the Arduino. So the first thing I decided to make is an enclosure filled with various parts so I can test out building something and working with my tools I have laying around. I'm not really sure what it is going to do yet. I was thinking maybe it would count down then light up a bunch of bright LED's. Kind of like a poor mans 'party button' if you have seen that (just look on youtube.) Here is the parts list for this build:
#define D1 8
#define D2 9
#define D3 10
#define D4 11
int ms = 1;
int digitPins[4] = {8, 9, 10, 11};
void setup() {
DDRD = B01111111;
for(int i=0; i < 4; i++) {
pinMode(digitPins[i], OUTPUT);
digitalWrite(digitPins[i], LOW);
}
zero();
delay(ms *100);
one();
delay(ms *100);
two();
delay(ms *100);
three();
delay(ms *100);
four();
delay(ms *100);
five();
delay(ms *100);
six();
delay(ms *100);
seven();
delay(ms *100);
eight();
delay(ms *100);
nine();
delay(ms *100);
for(int i=0; i < 4; i++) {
digitalWrite(digitPins[i], HIGH);
}
for(int i=0; i < 1000; i++) {
digitalWrite(digitPins[0], LOW);
PORTD = B01010010; // f
delay(3);
digitalWrite(digitPins[0], HIGH);
digitalWrite(digitPins[1], LOW);
PORTD = B01101100; // u
delay(3);
digitalWrite(digitPins[1], HIGH);
digitalWrite(digitPins[2], LOW);
PORTD = B01111000; // c
delay(3);
digitalWrite(digitPins[2], HIGH);
digitalWrite(digitPins[3], LOW);
PORTD = B00100010; // k
delay(3);
digitalWrite(digitPins[3], HIGH);
}
}
void loop() {
digitalWrite(digitPins[0], LOW);
zero();
digitalWrite(digitPins[0], HIGH);
digitalWrite(digitPins[1], LOW);
one();
digitalWrite(digitPins[1], HIGH);
digitalWrite(digitPins[2], LOW);
two();
digitalWrite(digitPins[2], HIGH);
digitalWrite(digitPins[3], LOW);
five();
digitalWrite(digitPins[3], HIGH);
}
void zero() {
PORTD = B00000100;
delay(ms);
}
void one() {
PORTD = B00101111;
delay(ms);
}
void two() {
PORTD = B00011000;
delay(ms);
}
void three() {
PORTD = B00001001;
delay(ms);
}
void four() {
PORTD = B00100011;
delay(ms);
}
void five() {
PORTD = B01000001;
delay(ms);
}
void six() {
PORTD = B01000000;
delay(ms);
}
void seven() {
PORTD = B00001111;
delay(ms);
}
void eight() {
PORTD = B00000000;
delay(ms);
}
void nine() {
PORTD = B00000011;
delay(ms);
}
Simple Larson Scanner/Cylon Eye
So the first thing I decided to make is an enclosure filled with various parts so I can test out building something and working with my tools I have laying around.
int green = 10; // Digital pin 10 - Green LED
int red = 6; // Digital pin 6 - Red LED
int blue = 5; // Digital pin 5 - Blue LED
int white = 3; // Digital pin 3 - Blue LED
int time = 1; // define delay element
int pulsewidth; // define pulsewidth (0-255)
int crappo;
void setup() {
for (pulsewidth=0; pulsewidth <= 255; pulsewidth++){
analogWrite(green, pulsewidth);
delay(time);
}
}
void loop() {
// slowly dim the LEDs
crappo = 0;
for (pulsewidth=255; pulsewidth >= 0; pulsewidth--){
analogWrite(green, pulsewidth);
analogWrite(red, crappo);
crappo = crappo + 1;
delay(time);
}
crappo = 0;
for (pulsewidth=255; pulsewidth >= 0; pulsewidth--){
analogWrite(red, pulsewidth);
analogWrite(blue, crappo);
crappo = crappo + 1;
delay(time);
}
crappo = 0;
for (pulsewidth=255; pulsewidth >= 0; pulsewidth--){
analogWrite(blue, pulsewidth);
analogWrite(white, crappo);
crappo = crappo + 1;
delay(time);
}
crappo = 0;
for (pulsewidth=255; pulsewidth >= 0; pulsewidth--){
analogWrite(white, pulsewidth);
analogWrite(blue, crappo);
crappo = crappo + 1;
delay(time);
}
crappo = 0;
for (pulsewidth=255; pulsewidth >= 0; pulsewidth--){
analogWrite(blue, pulsewidth);
analogWrite(red, crappo);
crappo = crappo + 1;
delay(time);
}
crappo = 0;
for (pulsewidth=255; pulsewidth >= 0; pulsewidth--){
analogWrite(red, pulsewidth);
analogWrite(green, crappo);
crappo = crappo + 1;
delay(time);
}
}
Easy Driver Stepper Controller
![]() This is my first try at making a schematic in Eagle. So working with a stepper motor controller.
// setup pins to control the stepper motor
int dirPin = 3;
int stepperPin = 2;
// setup pins for the switches
int switchPin = 7;
int switchPin_2 = 6;
// variables for reading the pin status
int val;
int val_2;
// variable to hold the last button state
int buttonState;
int buttonState_2;
void setup() {
// set stepper pins as outputs
pinMode(dirPin, OUTPUT);
pinMode(stepperPin, OUTPUT);
pinMode(switchPin, INPUT); // Set the switch pin as input
buttonState = digitalRead(switchPin); // read the initial state
pinMode(switchPin_2, INPUT); // Set the switch pin as input
buttonState_2 = digitalRead(switchPin_2); // read the initial state
}
void step(boolean dir,int steps){
digitalWrite(dirPin,dir);
delay(50);
for(int i=0;i |