Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 3:d837b1626ac2
- Parent:
- 2:8435af9e917a
- Child:
- 4:464ccaee7062
--- a/main.cpp Thu Feb 25 14:33:41 2016 +0000
+++ b/main.cpp Fri Feb 26 14:13:18 2016 +0000
@@ -32,7 +32,7 @@
DigitalOut pull28(PTD6);
DigitalOut pull29(PTD7);
-DigitalOut pull30(PTE30);
+//DigitalOut pull30(PTE30);
//DigitalOut pull38(PTE3);
DigitalOut pull39(PTE2);
@@ -55,7 +55,7 @@
PwmOut ENA(PTC9);
PwmOut ENB(PTD4);
-DigitalOut indicator(LED_BLUE);
+DigitalOut indicator(LED_GREEN);
//constant 3.3 volts for sensors
DigitalOut constant1(PTE5);
@@ -88,6 +88,24 @@
PwmOut motors(PTA12);
DigitalOut solenoid(PTA4);
+//Ball dispensing
+Ticker sine_interrupt;
+AnalogOut Aout(PTE30);
+double interrupt_f = .00001525878; // (1/2048*32)
+static int sine_wave_steps = 32; // number of steps in sine wave
+int sine_counter = 0;
+static float sine_val[] = {.5,.5976,.6914,.7773,.8535,.9160,.9619,.9902,1,.9902,.9619,.9160,.8535,.7773,.6914,.5976,.5,.4023,.3085,.2226,.1464,.0839,.0380,.0097,0,.0097,.0380,.0839,.1464,.2226,.3085,.4023};
+
+
+void create_sine() { //subroutine for interrupt, creates sine wave
+ sine_counter = sine_counter + 1; //run through sine array
+ if (sine_counter >= sine_wave_steps){
+ sine_counter = 0; //repeat sine wave
+ }
+ Aout = sine_val[sine_counter]; //output decimal 0-1 on DAC
+}
+
+
int main() {
@@ -121,7 +139,7 @@
pull27=0;
pull28=0;
pull29=0;
- pull30=0;
+ //pull30=0;
//pull34=0;
//pull35=0;
//pull38=0;
@@ -154,8 +172,6 @@
indicator=1;
wait(0.3);
indicator=0;
- wait(0.3);
- indicator=1;
ENA.period(0.001);
ENB.period(0.001);
@@ -167,7 +183,7 @@
//set inital pwm values for motor driver outputs
ENA=0;
ENB=0;
-
+ //You´ll never be the real slim shady
int counter=0;
while(1) {
@@ -201,13 +217,17 @@
ENA=0;
if(front==0){
//shoot balls
- motors=0.15;
+ motors=0.095;
wait_ms(550);
solenoid=1;
wait_ms(45);
solenoid=0;
+ }else{
+ //dispense balls
+ //sine_interrupt.attach(&create_sine , interrupt_f); // function called by interrupt, frequency of interrupts
}
- wait(3);
+ wait(3);
+ //__disable_irq();
motors=0;
}