Beruflich Dokumente
Kultur Dokumente
h>
#include <Servo.h>
#include <LiquidCrystal.h>
// Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13,12,6, 5, 4, 3); // Create an lcd object and assign the pins
(Rs,E,D4,D5,D6,D7)
// create a stepper object on pins 4, 5, 6 and 7
stepper stepper(STEPS, 14, 15, 16, 17); // pins for stepper motor
stepper.step(200);
// number of steps
int color_count[7] = {0 0 0 0 0 0 0}
brown empty
//red
blue
stepper.setSpeed(60);
int count = 0;
Servo_Motor
void setup() {
// set servo pin as output:
servo_motor.attach(servoPin);
// attaches the servo to pin 11
servo_motor.write(initial_angle);
// centering
delay(1000)
lcd.begin(16, 2); // Set the display to 16 columns and 2 rows
pause("Push button to", "start");
ing in order
}
void loop()
{
if (button_pause = 1) {
pause("pause", " ");
n program
}
attachInterrupt(0,button_pause,rising) //pin2
int color_angle = scan_color(); //determines color and return angle correspondin
g to color
lcd_counter(color_angle);
//displays how many m&m of given color
Void spin_stepper(); {
stepper.step(45);
delay(500)
}
Void isr_pause() {
button_pause = 1
}
//interrupt routine
Void isr_unpause() {
button_unpause = 1;
}
//interrupt routine
Case '120':
color_count[4] = color_count[4] +1;
lcd.clear(); // Clear the display
lcd.begin(6,0)
lcd.print("**BLUE**");
lcd.begin(8,1)
lcd.print(color_count[4]);
break;
Case '180':
color_count[5] = color_count[5] +1;
lcd.clear(); // Clear the display
lcd.begin(5,0)
lcd.print("**BROWN**");
lcd.begin(8,1)
lcd.print(color_count[5]);
break;
Case '15':
color_count[6] = color_count[6] +1;
lcd.clear(); // Clear the display
lcd.begin(5,0)
lcd.print("**EMPTY**");
lcd.begin(8,1)
lcd.print(color_count[6]);
break;
}
}
void test (int empty_reading)
{
if (int empty_reading = 15)
{
count = count++;
if (count = 3)
{
count = 0;
pause("pause"
}
}
else
{
count = 0;
}
}
" ");