Updated to latest version. Added in new version of the Siren
Dependencies: mbed-src
Fork of VolundrIntroCase2015 by
main.cpp
- Committer:
- tweaker1331
- Date:
- 2015-08-04
- Revision:
- 1:fad61b6e660b
- Parent:
- 0:9826a0b36948
- Child:
- 2:7ca8b2154664
File content as of revision 1:fad61b6e660b:
#include "mbed.h" /* MOTOR A ENA - p21 IN1 - p5 --> OUT1 - MOTORA+ IN2 - p6 --> OUT2 - MOTORA- MOTOR B ENB - p22 IN3 - p26 --> OUT3 - MOTORB+ IN4 - p25 --> OUT4 - MOTORB- */ PwmOut in1(p5); PwmOut in2(p6); PwmOut in3(p26); PwmOut in4(p25); DigitalOut en_a(p21); DigitalOut en_b(p22); DigitalOut LED(LED1); Serial bluetooth(p9, p10); //Serial pc(USBTX, USBRX); /* Initialize timers for the H-bridge*/ int init_drive() { // Set PWM frequency to 10 kHz in1.period_us(100); in2.period_us(100); in3.period_us(100); in4.period_us(100); /* Set enable pin high. NEVER set this pins low during driving. There are no protection diodes and with EN low, H-bridge is in Hi-Z mode. This can generate a high voltage that breaks the H-bridge.*/ en_a.write(1); en_b.write(1); return 1; } /*Handler for Bluetooth messages*/ void rxCallback() { char a; a = bluetooth.getc(); if(a == 'g') { LED = 1; } } /* Initialize the bluetooth module*/ int init_bluetooth() { bluetooth.baud(9600); //wait(0.2); //bluetooth.printf("AT+NAMETHOR1\r\n"); bluetooth.attach(&rxCallback, Serial::RxIrq); return 1; } /* Initialize ADC ports*/ int init_ADC() { return 1; } /* Initialize GPIO's*/ int init_GPIO() { return 1; } int main() { init_drive(); init_bluetooth(); while(1) { /* if(pc.readable()) { bluetooth.putc(pc.getc()); } if(bluetooth.readable()) { pc.putc(bluetooth.getc()); }*/ } }