Coursework

Revision:
2:bb3dbda4d1f5
Parent:
1:757728321abd
Child:
3:6ecb75a2675c
diff -r 757728321abd -r bb3dbda4d1f5 main.cpp
--- a/main.cpp	Thu Dec 16 14:40:46 2021 +0000
+++ b/main.cpp	Thu Dec 16 15:48:10 2021 +0000
@@ -2,10 +2,11 @@
 #include "Joystick.h"
 #include "N5110.h"
 #include "hcsr04.h"
+#include "pwm_tone.h"
 //                  y     x     button
 Joystick joystick(PTB10,PTB11,PTC16);
 HCSR04 sensor(D14, D15); 
-
+PwmOut Buzzer(PTC10);
 
 //      rows,cols
 int sprite[8][5] =   {
@@ -28,22 +29,27 @@
     // change set contrast in range 0.0 to 1.0
     // 0.5 appears to be a good starting point
    lcd.setContrast(0.5);
+    //     Buzzer.period(10.0f);
+    //Buzzer.pulsewidth(1);   
     
     while(1) {
+Auto_tunes(Buzzer,Do3,16);
         long distanced = sensor.distance(); 
         if (distanced >= 400 || distanced <= 2) 
     {
         printf("Out of range");
         wait(1.0);
     }
-    
+   
     else
     
     {
       printf("Distance :  %d cm",distanced);
       wait(1.0); // 1 sec  
     }
-
+ lcd.drawCircle(WIDTH/2,HEIGHT/2,distanced,FILL_BLACK); 
+ lcd.refresh();
+ wait(5.0);
         // these are default settings so not strictly needed
         lcd.normalMode();      // normal colour mode
         lcd.setBrightness(0.5); // put LED backlight on 50%