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.
Diff: main.cpp
- Revision:
- 2:065d789dbcbd
- Parent:
- 0:b8bade04f24f
- Child:
- 3:cb420000788e
diff -r b8bade04f24f -r 065d789dbcbd main.cpp --- a/main.cpp Thu Sep 03 21:45:56 2020 +0000 +++ b/main.cpp Fri Oct 23 14:26:16 2020 +0000 @@ -4,6 +4,7 @@ #include "soft_uart.h" #include <string.h> #include "ArduCAM2640.h" +#include "Servo/Servo.h" #define IMAGE_JPG_SIZE 16*1024 #define MIN(x,y) x < y ? x : y float sum = 0; @@ -11,6 +12,9 @@ char buffer[14]; char buf[100]; unsigned int framepos=0; + +Servo servo_pan(PB_0); +Servo servo_tilt(PB_1); ArduCAM2640 g_arducam; I2C camI2C(PB_7, PB_6); //I2C camI2C(PB_7,PB_6); //SDA/SCL @@ -28,7 +32,7 @@ SDFileSystem sd(PB_5, PB_4, PB_3, PA_11, "sd"); //MOSI,MISO,SCK,CS the pinout on the mbed Cool Components workshop board // activation 3.3V power supply on sensors board -DigitalOut activ_sensors(PA_7); // +DigitalOut activ_sensors(PA_12); // // Analog pin sensors : battery and temperature AnalogIn batin(PA_0);//battery pin pA0 AnalogIn tempin(PA_1);//temperature pin pa1 @@ -318,6 +322,35 @@ pc.printf("\r\nbye bye..."); exit(0); } + +void test_pan_tilt(void) +{unsigned char stop=0; + pc.printf("\r\n/*----------------------------------------------*/\r\n"); + pc.printf("\t Pan Tilt test\r\n"); + pc.printf("send \"s\" to stop\r\n"); + pc.printf("/*----------------------------------------------*/\r\n"); + wait(2); + do + { + for(float p=0.2; p<0.7; p += 0.1) + { + servo_pan = p; + servo_tilt=p; + wait(0.4); + } + for(float p=0.7; p>0.2; p -= 0.1) + { + servo_pan = p; + servo_tilt=p; + wait(0.4); + } + if(pc.readable()) + stop=pc.getc(); + }while(stop!='s'); + servo_pan = 0.5; + servo_tilt=0.5; +} + int menu(void) {int choice=0; // menu tests @@ -330,13 +363,14 @@ pc.printf("\t4. Test CAMERA\r\n"); pc.printf("\t5. Test temperature sensor & battery level \r\n"); pc.printf("\t6. Test XBEE communication\r\n"); - pc.printf("\t7. Quit\r\n"); + pc.printf("\t7. Test pan/tilt plates \r\n"); + pc.printf("\t8. Quit\r\n"); pc.printf("/*-------------------------------------------*/\r\n"); do { - pc.printf("Please enter your choice (1 to 7):"); + pc.printf("Please enter your choice (1 to 8):"); choice=pc.getc(); - }while(choice<0x31||choice>0x37); + }while(choice<0x31||choice>0x38); return choice; } @@ -388,10 +422,13 @@ break; case '6' : test_xbee_comm(); status=0; - break; + break; + case '7' : test_pan_tilt(); + status=0; + break; //case 7: all_test(); // break; - case '7' : quit(); + case '8' : quit(); break; } }