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:
- 0:3e6bb88dd7ee
- Child:
- 2:6acc2f4efd39
- Child:
- 1:3ae60fd51e2b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat Sep 29 22:47:56 2018 +0000
@@ -0,0 +1,97 @@
+#include "mbed.h"
+#include "TextLCD.h"
+
+void settemp();
+void tempmenu();
+float temp_cal();
+AnalogIn temp_sen(A0);
+TextLCD lcd(PTC7,PTC0,PTC3,PTC4,PTC5,PTC6);
+InterruptIn button(D0);
+DigitalIn push2(D1);
+DigitalIn push1(D2);
+DigitalIn push3(D3);
+PwmOut mypwm(A5);
+//DigitalOut myled(A);
+
+int temp = 25;
+float tempC,tempF,a[10],avg;
+
+int main() {
+ tempmenu();
+}
+
+void settemp(){
+ lcd.cls();
+ lcd.printf("enter temp: %d",temp);
+ wait(0.2);
+ while(1){
+
+ // temp up
+ if(push2 == 0 && push1 == 1){
+ temp++;
+ lcd.cls();
+ lcd.printf("enter temp: %d",temp);
+ wait(0.2);
+ }
+
+ // temp down
+ if(push1 == 0 && push2 == 1){
+ temp--;
+ lcd.cls();
+ lcd.printf("enter temp: %d",temp);
+ wait(0.2);
+ }
+
+ // confirm
+ if(push3 == 0){
+// tempmenu();
+ break;
+ }
+
+ }
+}
+
+void tempmenu() {
+ while(1){
+ lcd.cls();
+ // display menu
+ mypwm.period_ms(10);
+ lcd.printf("T:%.2f \n",temp_cal());
+ lcd.printf("1 to mod temp");
+ wait(0.2);
+ if(temp_cal()<temp){
+ wait(0.5);
+ mypwm.pulsewidth_ms(8);
+ }
+ if(temp_cal()>=temp){
+ mypwm.pulsewidth_ms(2);
+ }
+
+ //else{
+ //myled =0;}
+ // interrupt
+ button.fall(&settemp);
+ lcd.printf("end");
+ }
+}
+
+float temp_cal(){
+ avg=0;
+ int i;
+for(i=0;i<10;i++)
+{
+a[i]=temp_sen.read();
+wait(.05);
+}
+for(i=0;i<10;i++)
+{
+avg=avg+(a[i]/10);
+}
+
+
+tempC=(avg*3.685503686*100);
+tempF=(9.0*tempC)/5.0 + 32.0;
+return tempC;
+ }
+
+