<?xml version="1.0"?>
<rss version="2.0">
   <channel>
      <title>Remake of Embedded Assignment by Muhammad Khalish Zainudin</title>
      <link>https://padlet.com/khalish18/Coding</link>
      <description>Made with a lightning strike of genius</description>
      <language>en-us</language>
      <pubDate>2019-05-21 15:57:33 UTC</pubDate>
      <lastBuildDate>2026-02-10 21:26:55 UTC</lastBuildDate>
      <webMaster>hello@padlet.com</webMaster>
      <image>
         <url></url>
      </image>
      <item>
         <title>Embedded</title>
         <author>khalish18</author>
         <link>https://padlet.com/khalish18/Coding/wish/362203089</link>
         <description><![CDATA[<div>/* Embedded Assignment Sem 2, 2018/2019<br><br>- Fikry<br>- Khalish<br>- Amirul<br>- Nakib<br>- Syakir<br>                                                   <br>         <br>                                                   */<br>#include "mbed.h"<br>#include "TextLCD.h"            // library for LCD Display<br><br>TextLCD lcd(p21, p22, p17, p18, p19, p20); // rs, e, d0, d1, d2, d3 pin out for LCD<br><br>DigitalIn press(p14);            // Joy stick button<br>BusIn Up(p15);                   // Joy stick<br>BusIn Down(p12);                 // Joy stick<br>BusIn Left(p13);                 // Joy stick<br>BusIn Right(p16);                // Joy stick <br><br>int y[3]={00,00,00};<br>char day[7][40] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};<br><br>// function for time <br>void time(){<br>    int i = 0;<br>    for(int m=0;m&lt;7;m++){<br>        for(int k=1;k&lt;=12;k++){<br>            for(int j=0;j&lt;60;j++){<br>                y[2] = 0; // reset seconds into 0<br>                <br>                for(i=0;i&lt;60;i++){<br>                    y[0] = k;<br>                    y[1] = j;<br>                            <br>                    lcd.cls();<br>                    lcd.locate(0,0);                                // locate time<br>                    lcd.printf("%d : %d : %d",y[0],y[1],y[2]);      // print time<br>                            <br>                    lcd.locate(0,1);                                // locate day<br>                    lcd.printf("%s",day[m]);                        // print day<br>                            <br>                    y[2]++;<br>                            <br>                    wait(1);   <br>                } // end for loop i (sec)      <br>            } // end for loop j (min)     <br>        } // end for loop k (hour)  <br>    } // end for loop m (days)<br>}<br><br><br>// main function<br>int main() {<br>    // start program<br>    lcd.printf("Press button to set time");<br>    <br>    while(1){<br>        // wait for input from user - joy stick button<br>        if(press==true){<br>            int x=0;<br>            <br>            lcd.cls();<br>            lcd.locate(0,0);<br>            lcd.printf("%d:%d:%d",y[0],y[1],y[2]);      // locate time<br>            <br>            wait(0.5);<br>            <br>            while(1){<br>                lcd.locate(0,0);<br>                lcd.printf("%d:%d:%d",y[0],y[1],y[2]);      // locate time<br>                <br>                lcd.locate(0,1);                            // locate text    <br>                <br>                // Operations by Joystic<br>                if (Up){<br>                    lcd.printf("                 ");<br>                    lcd.locate(0,1);            <br>                    lcd.printf("UP");<br>                    <br>                    y[x]++;<br>                    wait(0.5);<br>                } // end if (up)<br>                    <br>                if (Down){<br>                    lcd.printf("                 ");<br>                    lcd.locate(0,1);<br>                    lcd.printf("Down");<br>                    <br>                    y[x]--;<br>                    wait(0.5);<br>                } // end if (down)<br>                    <br>                if (Left){<br>                    if(x==0){<br>                        lcd.printf("                 ");<br>                        lcd.locate(0,1);<br>                        lcd.printf("Left");<br>                        <br>                        x=2;<br>                        wait(0.5);<br>                    } // end if<br>                    <br>                    else{<br>                        lcd.printf("                 ");<br>                        lcd.locate(0,1);<br>                        lcd.printf("Left");<br>                        <br>                        x--;<br>                        wait(0.5);<br>                    } // end else<br>                } // end if (left)<br>                    <br>                if (Right){<br>                    if(x==2){<br>                        lcd.printf("                 ");            <br>                        lcd.locate(0,1);<br>                        lcd.printf("Right");<br>                        <br>                        x=0;<br>                        wait(0.5);<br>                    } // end if<br>                    <br>                    else{<br>                        lcd.printf("                 ");            <br>                        lcd.locate(0,1);<br>                        lcd.printf("Right");<br>                        <br>                        x++;<br>                        wait(0.5);<br>                    } // end else<br>                } // end if (right)<br>            } // end while loop<br>         } // end if (user press)<br>         <br>         else{<br>             time();<br>         }<br>    } // end while loop<br>} // end main<br><br><br></div>]]></description>
         <enclosure url="" />
         <pubDate>2019-05-21 15:57:49 UTC</pubDate>
         <guid>https://padlet.com/khalish18/Coding/wish/362203089</guid>
      </item>
      <item>
         <title>Arduino to ThingSpeak</title>
         <author>khalish18</author>
         <link>https://padlet.com/khalish18/Coding/wish/362420997</link>
         <description><![CDATA[<div><br>/* Arduino+esp8266 thingSpeak example  <br> * Example name = "Write temperature and humidity to Thingspeak channel"<br> * Created by Ilias Lamprou<br> * Updated Oct 30 2016<br> * <br> * Download latest Virtuino android app from the link:https://play.google.com/store/apps/details?id=com.virtuino_automations.virtuino&amp;hl<br> * Video tutorial link: https://youtu.be/4XEe0HY0j6k<br> * Contact address for questions or comments: iliaslampr@gmail.com<br> */<br><br>// Code to use SoftwareSerial<br>#include &lt;SoftwareSerial.h&gt;<br>SoftwareSerial espSerial =  SoftwareSerial(2,3);      // arduino RX pin=2  arduino TX pin=3    connect the arduino RX pin to esp8266 module TX pin   -  connect the arduino TX pin to esp8266 module RX pin<br><br><br><br>#include &lt;DHT.h&gt;        //Attention: For new  DHT11 version  library you will need the Adafruit_Sensor library<br>                        //Download from here: https://github.com/adafruit/Adafruit_Sensor<br><br><br>#define DHTPIN 5                // Connect the signal pin of DHT22 sensor to digital pin 5<br>#define ldrPin A0   // analog output for LDR<br><br>#define DHTTYPE DHT22 <br>DHT dht(DHTPIN, DHTTYPE);<br><br><br>String apiKey = "SR1PXN9VTNFJ4YS0";     // replace with your channel's thingspeak WRITE API key<br><br>String ssid="Bruno";    // Wifi network SSID<br>String password ="abcde12345";  // Wifi network password<br><br>boolean DEBUG=true;<br><br>//======================================================================== showResponce<br>void showResponse(int waitTime){<br>    long t=millis();<br>    char c;<br>    while (t+waitTime&gt;millis()){<br>      if (espSerial.available()){<br>        c=espSerial.read();<br>        if (DEBUG) Serial.print(c);<br>      }<br>    }<br>                   <br>}<br><br>//========================================================================<br>boolean thingSpeakWrite(float value1, float value2, float value3){<br>  String cmd = "AT+CIPSTART=\"TCP\",\"";                  // TCP connection<br>  cmd += "184.106.153.149";                               // api.thingspeak.com<br>  cmd += "\",80";<br>  espSerial.println(cmd);<br>  if (DEBUG) Serial.println(cmd);<br>  if(espSerial.find("Error")){<br>    if (DEBUG) Serial.println("AT+CIPSTART error");<br>    return false;<br>  }<br>  <br>  <br>  String getStr = "GET /update?api_key=";   // prepare GET string<br>  getStr += apiKey;<br>  <br>  getStr +="&amp;field1=";<br>  getStr += String(value1);<br>  getStr +="&amp;field2=";<br>  getStr += String(value2);<br>  <br>  getStr += "&amp;field3=";<br>  getStr += String(value3);<br>  <br>  // getStr +="&amp;field4=";<br>  // getStr += String(value4);<br>  // ...<br>  getStr += "\r\n\r\n";<br><br>  // send data length<br>  cmd = "AT+CIPSEND=";<br>  cmd += String(getStr.length());<br>  espSerial.println(cmd);<br>  if (DEBUG)  Serial.println(cmd);<br>  <br>  delay(100);<br>  if(espSerial.find("&gt;")){<br>    espSerial.print(getStr);<br>    if (DEBUG)  Serial.print(getStr);<br>  }<br>  else{<br>    espSerial.println("AT+CIPCLOSE");<br>    // alert user<br>    if (DEBUG)   Serial.println("AT+CIPCLOSE");<br>    return false;<br>  }<br>  return true;<br>}<br>//================================================================================ setup<br><br><br>//int ldrPin = 7;<br><br>void setup() {                <br>  DEBUG=true;           // enable debug serial<br><br>  pinMode(ldrPin, INPUT);<br>  <br>  Serial.begin(9600); <br>  <br>  dht.begin();          // Start DHT sensor<br>  <br>  <br>  <br>  espSerial.begin(9600);  // enable software serial<br>                          // Your esp8266 module's speed is probably at 115200. <br>                          // For this reason the first time set the speed to 115200 or to your esp8266 configured speed <br>                          // and upload. Then change to 9600 and upload again<br>  <br>  //espSerial.println("AT+RST");         // Enable this line to reset the module;<br>  //showResponse(1000);<br><br>  //espSerial.println("AT+UART_CUR=9600,8,1,0,0");    // Enable this line to set esp8266 serial speed to 9600 bps<br>  //showResponse(1000);<br><br>  // start wifi conenction<br>  Serial.println("Start");<br><br>  espSerial.println("AT+CWMODE=1");   // set esp8266 as client<br>  showResponse(5000);<br><br>  espSerial.println("AT+CWJAP=\""+ssid+"\",\""+password+"\"");  // set your home router SSID and password<br>  showResponse(5000);<br><br>   if (DEBUG)  Serial.println("Setup completed");<br>}<br><br><br>// ====================================================================== loop<br>void loop() {<br><br>  // Read sensor values<br>  <br>  int ldrStatus = analogRead(ldrPin);<br>  <br>  if (ldrStatus &lt;= 520) {                               // ldr status bright&gt;520, dark&lt;=520<br>    Serial.print("Its DARK, Turn on the LED : ");<br>    Serial.println(ldrStatus);<br>    } <br>    else {<br>    Serial.print("Its BRIGHT, Turn off the LED : ");<br>    Serial.println(ldrStatus);<br>    }<br>  <br>  float f = ldrStatus;<br>  <br>  float t = dht.readTemperature();<br>  float h = dht.readHumidity();<br>        if (isnan(t) || isnan(h)) {<br>        if (DEBUG) Serial.println("Failed to read from DHT");<br>      }<br>      else {<br>          if (DEBUG)  Serial.println("Temp="+String(t)+" *C");<br>          if (DEBUG) Serial.println("Humidity="+String(h)+" %");<br>           thingSpeakWrite(t,h,f);                                      // Write values to thingspeak<br>      }<br>  <br>    <br>  // thingspeak needs 15 sec delay between updates,     <br>  delay(20000);  <br>}</div>]]></description>
         <pubDate>2019-05-22 06:22:37 UTC</pubDate>
         <guid>https://padlet.com/khalish18/Coding/wish/362420997</guid>
      </item>
      <item>
         <title>done 2</title>
         <author></author>
         <link>https://padlet.com/khalish18/Coding/wish/362844159</link>
         <description><![CDATA[<div>/* Embedded Assignment Sem 2, 2018/2019<br><br>- Fikry<br>- Khalish<br>- Amirul<br>- Nakib<br>- Syakir<br>                                                   <br>         <br>                                                   */<br>#include "mbed.h"<br>#include "TextLCD.h"            // library for LCD Display<br><br>TextLCD lcd(p21, p22, p17, p18, p19, p20); // rs, e, d0, d1, d2, d3 pin out for LCD<br><br>DigitalIn press(p14);            // Joy stick button<br>BusIn Up(p15);                   // Joy stick<br>BusIn Down(p12);                 // Joy stick<br>BusIn Left(p13);                 // Joy stick<br>BusIn Right(p16);                // Joy stick <br><br>int y[4]={00,00,00,00};<br>char day[7][40] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};<br><br><br>//=================================== function for time display =================================<br><br><br>// function for time <br>void time(int hour, int min, int sec){<br>    <br>    for(int m=0;m&lt;7;m++){<br>    <br>        for(int k=1;k&lt;=12;k++){<br>            if(hour != 1){<br>                k = hour;   <br>            }<br>            <br>            for(int j=0;j&lt;60;j++){<br>                if(min != 0){<br>                    j = min;<br>                }                                               <br>                <br>                for(int i=0;i&lt;60;i++){<br>                    if(sec != 0){<br>                        i = sec;    <br>                    }                                                       <br>                            <br>                    lcd.cls();<br>                    lcd.locate(0,0);                                // locate time<br>                    lcd.printf(" %d: %d: %d: ", k, j, i);      // print time<br>                            <br>                    //lcd.locate(0,1);                                // locate day<br>                    lcd.printf("%s", day[m]);                        // print day<br>                            <br>                    i++;<br>                    sec = 0;<br>                            <br>                    wait(0.2);   <br>                } // end for loop i (sec)     <br>                <br>                min = 0; <br>            } // end for loop j (min)<br>            <br>            hour = 1;     <br>        } // end for loop k (hour)  <br>    } // end for loop m (days)<br>}<br><br><br><br>//==================================== main function ============================================<br><br>int main() {<br>    // start program<br>    lcd.printf("Press button to set time");<br>    <br>    while(1){<br>        // wait for input from user - joy stick button<br>        if(press==true){<br>            int x=0;<br>            int dayN = 0;<br>            <br>            lcd.cls();<br>            lcd.locate(0,0);<br>            lcd.printf("%d:%d:%d",y[0],y[1],y[2]);      // locate time<br>            <br>            wait(0.5);<br>            <br>            while(1){<br>                lcd.locate(0,0);<br>                lcd.printf("%d:%d:%d",y[0],y[1],y[2]);          // locate time<br>                lcd.locate(0,1);                                 // locate text    <br><br>                // choosing the array <br>                if(x==0){<br>                    lcd.printf("                 ");<br>                    lcd.locate(0,1);            <br>                    lcd.printf("Hour");<br>                    }<br>                if(x==1){<br>                    lcd.printf("                 ");<br>                    lcd.locate(0,1);            <br>                    lcd.printf("Minute");<br>                    }<br>                if(x==2){<br>                    lcd.printf("                 ");<br>                    lcd.locate(0,1);            <br>                    lcd.printf("Sec");<br>                    }            <br>                if(x==3){<br>                    lcd.printf("                 ");<br>                    lcd.locate(0,1);            <br>                    lcd.printf("DONE ? - Press!! ");<br>                }<br>                                <br>                <br>                //=================== Operations by Joystic ==========================<br>                <br>                <br>                //=================== press up<br>                if (Up){                                 <br>                    y[x]++;<br>                    wait(0.5);<br>                } // end if (up)<br>                <br>                <br>                //=================== press down        <br>                if (Down){<br>                    y[x]--;<br>                    wait(0.5);<br>                } // end if (down)<br>                <br>                <br>                //=================== press left    <br>                if (Left){<br>                    if(x==0){                      <br>                        x=3;<br>                        wait(0.5);<br>                    } // end if<br>                    <br>                    else{<br>                        x--;<br>                        wait(0.5);<br>                    } // end else<br>                } // end if (left)<br>                    <br>                <br>                //=================== press right   <br>                if (Right){<br>                    if(x==3){<br>                        x=0;<br>                        wait(0.5);<br>                    } // end if<br>                    <br>                    else{<br>                        x++;<br>                        wait(0.5);<br>                    } // end else<br>                } // end if (right)<br>                <br>                <br>                //=================== press joystic<br>                if(x==3){<br>                    if(press==true){<br>                        time(y[0], y[1], y[2]);<br>                    }<br>                }<br>                <br>                <br>            } // end while loop<br>         } // end if (user press)<br>         <br>         /*else{<br>             time();<br>         }*/<br>         <br>    } // end while loop<br>} // end main</div>]]></description>
         <enclosure url="" />
         <pubDate>2019-05-23 08:55:33 UTC</pubDate>
         <guid>https://padlet.com/khalish18/Coding/wish/362844159</guid>
      </item>
      <item>
         <title>Done 4 - MainMenu </title>
         <author></author>
         <link>https://padlet.com/khalish18/Coding/wish/362900493</link>
         <description><![CDATA[<div> /* Embedded Assignment Sem 2, 2018/2019<br><br>- Fikry<br>- Khalish<br>- Amirul<br>- Nakib<br>- Syakir<br>                                                   <br>         <br>                                                   */<br>#include "mbed.h"<br>#include "TextLCD.h"            // library for LCD Display<br><br>TextLCD lcd(p21, p22, p17, p18, p19, p20); // rs, e, d0, d1, d2, d3 pin out for LCD<br><br>DigitalIn press(p14);            // Joy stick button<br>BusIn Up(p15);                   // Joy stick<br>BusIn Down(p12);                 // Joy stick<br>BusIn Left(p13);                 // Joy stick<br>BusIn Right(p16);                // Joy stick <br><br>int y[4]={00,00,00,00};<br>char day[7][40] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};<br><br>char menu[2][40] = {"Set Time", "Set Alarm"};<br><br><br>//=================================== function for time display =================================<br><br>// function for time <br>void time(int hour, int min, int sec){<br>    <br>    for(int m=0;m&lt;7;m++){<br>    <br>        for(int k=1;k&lt;=12;k++){<br>            if(hour != 1){<br>                k = hour;   <br>            }<br>            <br>            for(int j=0;j&lt;60;j++){<br>                if(min != 0){<br>                    j = min;<br>                }                                               <br>                <br>                for(int i=0;i&lt;60;i++){<br>                    if(sec != 0){<br>                        i = sec;    <br>                    }                                                       <br>                            <br>                    lcd.cls();<br>                    lcd.locate(0,0);                                // locate time<br>                    lcd.printf("%d:%d:%d", k, j, i);      // print time<br>                            <br>                    lcd.locate(0,1);                                // locate day<br>                    lcd.printf("%s", day[m]);                        // print day<br>                            <br>                    i++;<br>                    sec = 0;<br>                            <br>                    wait(0.2);   <br>                } // end for loop i (sec)     <br>                <br>                min = 0; <br>            } // end for loop j (min)<br>            <br>            hour = 1;     <br>        } // end for loop k (hour)  <br>    } // end for loop m (days)<br>}<br><br><br><br>//==================================== set time function ============================================<br><br>void setTime(){<br>            int x=0;<br>            <br>            lcd.cls();<br>            lcd.locate(0,0);           <br>            lcd.printf("%d:%d:%d",y[0],y[1],y[2]);      // locate time<br>            <br>            wait(0.5);<br>            <br>            while(1){<br>                lcd.locate(0,0);<br>                lcd.printf("%d:%d:%d",y[0],y[1],y[2]);          // locate time<br>                  lcd.locate(0,1);                             // locate text    <br><br>                // choosing the array <br>                if(x==0){<br>                    lcd.printf("                 ");<br>                    lcd.locate(0,1);            <br>                    lcd.printf("Hour");<br>                    wait(0.05);<br>                    }<br>                if(x==1){<br>                    lcd.printf("                 ");<br>                    lcd.locate(0,1);            <br>                    lcd.printf("Minute");<br>                    wait(0.05);<br>                    }<br>                if(x==2){<br>                    lcd.printf("                 ");<br>                    lcd.locate(0,1);            <br>                    lcd.printf("Second");<br>                    wait(0.05);<br>                    }            <br>                if(x==3){<br>                    lcd.printf("                 ");<br>                    lcd.locate(0,1);            <br>                    lcd.printf("DONE? - Press!! ");<br>                    wait(0.05);<br>                }<br>                                <br>                <br>                //=================== Operations by Joystic ==========================<br>                <br>                //=================== press up<br>                if (Up){<br>                    // limit for hour<br>                    if(x==0){           <br>                        if(y[0]&gt;11){<br>                        y[0]=0;<br>                        wait(0.5);}<br>                    }<br>                    // limit for minute<br>                    if(x==1){<br>                        if(y[1]&gt;58){<br>                        y[1]=0-1;<br>                        wait(0.5);}<br>                    }<br>                    // limit for seconds<br>                    if(x==2){<br>                        if(y[2]&gt;58){<br>                        y[2]=0-1;<br>                        wait(0.5);}<br>                    }<br>                        <br>                    if(y[0]!=12||y[1]!=60||y[2]!=60){                <br>                        y[x]++;<br>                        wait(0.5);}<br>                } // end if (up)               <br>                <br>                //=================== press down        <br>                if (Down){<br>                    // limit for hour<br>                    if(x==0){<br>                        if(y[0]&lt;2){<br>                        y[0]=13;<br>                        wait(0.5);}<br>                    }<br>                    // limit for minute<br>                    if(x==1){<br>                        if(y[1]&lt;1){<br>                        y[1]=60;<br>                        wait(0.5);}<br>                    }<br>                    // limit for seconds<br>                    if(x==2){<br>                        if(y[2]&lt;1){                <br>                        y[2]=60;<br>                        wait(0.5);}<br>                    }<br>                        <br>                    if(y[0]!=0 || y[1]!=0 || y[2]!=0){            <br>                        y[x]--;<br>                        wait(0.5);<br>                    }                    <br>                } // end if (down)<br>                <br>                <br>                //=================== press left    <br>                if (Left){<br>                    if(x==0){                      <br>                        x=3;<br>                        wait(0.5);<br>                    } // end if<br>                    <br>                    else{<br>                        x--;<br>                        wait(0.5);<br>                    } // end else<br>                } // end if (left)<br>                    <br>                <br>                //=================== press right   <br>                if (Right){<br>                    if(x==3){<br>                        x=0;<br>                        wait(0.5);<br>                    } // end if<br>                    <br>                    else{<br>                        x++;<br>                        wait(0.5);<br>                    } // end else<br>                } // end if (right)<br>                <br>                <br>                //=================== press joystic<br>                if(x==3){<br>                    if(press==true){<br>                        time(y[0], y[1], y[2]);<br>                    }<br>                }<br>                <br>                <br>            } // end while loop<br>}<br><br><br><br>//==================================== set alarm function ============================================<br><br>void setAlarm(){<br>    lcd.cls();<br>    lcd.locate(0,0);<br>    lcd.printf("----SET ALARM HERE--------");<br>    wait(0.5);<br>}<br><br><br>//==================================== main function ============================================<br><br>int main() {<br>    // start program<br>    lcd.printf("Welcome");<br>    wait(1);<br>    <br>    // main<br>    lcd.locate(0,0);<br>    lcd.printf("Main Menu");<br>    wait(1);<br>    <br>    lcd.locate(1,0);<br>    <br>    while(1){<br>        // wait for input from user - joy stick button<br>        int x;<br>        <br>        //=================== press up<br>        if (Up){                                 <br>            x=0;<br>            lcd.cls();<br>            lcd.locate(0,0);<br>            lcd.printf("%s", menu[x]);            <br>        } // end if (up)<br>                <br>        //=================== press down        <br>        if (Down){<br>            x=1;<br>            lcd.cls();<br>            lcd.locate(0,0);<br>            lcd.printf("%s", menu[x]);<br>        } // end if (down)<br>        <br>        <br>        if(press){ <br>            if(x==0){<br>                setTime();<br>            }<br>            <br>            if(x==1){<br>                setAlarm();<br>            }<br>        }     <br>         <br>    } // end while loop<br>} // end main</div>]]></description>
         <enclosure url="" />
         <pubDate>2019-05-23 12:39:30 UTC</pubDate>
         <guid>https://padlet.com/khalish18/Coding/wish/362900493</guid>
      </item>
      <item>
         <title>FINAL</title>
         <author>khalish18</author>
         <link>https://padlet.com/khalish18/Coding/wish/363013550</link>
         <description><![CDATA[<div> /* Embedded Assignment Sem 2, 2018/2019<br><br>- Fikry<br>- Khalish<br>- Amirul<br>- Nakib<br>- Syakir<br>                                                   <br>         <br>                                                   */<br>#include "mbed.h"<br>#include "TextLCD.h"            // library for LCD Display<br><br>TextLCD lcd(p21, p22, p17, p18, p19, p20); // rs, e, d0, d1, d2, d3 pin out for LCD<br><br>DigitalIn press(p14);            // Joy stick button<br>BusIn Up(p15);                   // Joy stick<br>BusIn Down(p12);                 // Joy stick<br>BusIn Left(p13);                 // Joy stick<br>BusIn Right(p16);                // Joy stick <br><br>PwmOut speaker(p26);             // Speaker<br><br>int y[3]={00,00,00};<br>int alarm[3]={00,00,00};<br><br>char day[7][40] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};<br><br>char menu[2][40] = {"1. Set Timer", "2. Set Alarm"};<br><br>//=================================== buzzer ====================================================<br><br>void playAlarm(){<br>    <br>    lcd.cls();<br>    lcd.locate(0,0);<br>    lcd.printf("-- ALARM !!!! --");<br>    <br>    lcd.locate(0,1);<br>    lcd.printf("Press Anything");<br>    <br>    while(1){<br>        for (float i=2000.0; i&lt;10000.0; i+=500) {<br>            speaker.period(1.0/i);<br>            speaker=0.5;<br>            wait(0.1);<br>        }    <br>        <br>        if(press){<br>            for (float i=2000.0; i&lt;10000.0; i+=500) {<br>                speaker.period(1.0/i);<br>                speaker=1.0;<br>                wait(0.1);<br>            } <br>            return;    <br>        }<br>    }    <br>}<br><br><br>//=================================== function for time display =================================<br><br>// function for time <br>void time(int hour, int min, int sec){<br>    <br>    for(int m=0;m&lt;7;m++){<br>    <br>        for(int k=1;k&lt;=12;k++){<br>            if(hour != 1){<br>                k = hour;   <br>            }<br>            <br>            for(int j=0;j&lt;60;j++){<br>                if(min != 0){<br>                    j = min;<br>                }                                               <br>                <br>                for(int i=0;i&lt;60;i++){<br>                    if(sec != 0){<br>                        i = sec;    <br>                    }                                                       <br>                            <br>                    lcd.cls();<br>                    lcd.locate(2,0);                                // locate time<br>                    lcd.printf(" %d : %d : %d ", k, j, i);      // print time<br>                            <br>                    lcd.locate(0,1);                                // locate day<br>          //          lcd.printf("%s", day[m]);                        // print day<br>                    <br>                    if(alarm[0]==0 &amp;&amp; alarm[1]==0 &amp;&amp; alarm[2]==0){<br>                        lcd.printf("No Alarm Set");<br>                    }<br>                    <br>                    else{<br>                        lcd.printf("*Alarm: %d:%d:%d", alarm[0],alarm[1],alarm[2]);    <br>                    }<br>                    <br>                    if(k==alarm[0] &amp;&amp; j==alarm[1] &amp;&amp; i==alarm[2]){<br>                        playAlarm();    <br>                    }<br>                    <br>                    if(Left){<br>                        flag = 1;<br>                        return;<br>                    }                                       <br>                            <br>                    i++;<br>                    sec = 0;<br>                            <br>                    wait(0.2);   <br>                } // end for loop i (sec)     <br>                <br>                min = 0; <br>            } // end for loop j (min)<br>            <br>            hour = 1;     <br>        } // end for loop k (hour)  <br>    } // end for loop m (days)<br>}<br><br><br>//==================================== set time function ============================================<br><br>void setTime(){            <br>    <br>    lcd.cls();<br>    lcd.locate(0,0);<br>    lcd.printf("-- Set Time --");<br>    wait(1);<br>            <br>    int x=0;<br>            <br>    lcd.cls();<br>            <br>    y[0] = 0;<br>    y[1] = 0;<br>    y[2] = 0;<br>            <br>    while(1){<br>        lcd.locate(2,0);                <br>        lcd.printf(" %d : %d : %d ",y[0],y[1],y[2]);          // locate time<br>                <br>        lcd.locate(0,1);                             // locate text    <br><br>        // choosing the array <br>        if(x==0){              <br>            lcd.printf("                 ");<br>            lcd.locate(0,1);            <br>            lcd.printf("Hour");<br>            wait(0.05);<br>        }<br>        if(x==1){<br>            lcd.printf("                 ");<br>            lcd.locate(0,1);            <br>            lcd.printf("Minute");<br>            wait(0.05);<br>        }<br>        if(x==2){<br>            lcd.printf("                 ");<br>            lcd.locate(0,1);            <br>            lcd.printf("Second");<br>            wait(0.05);<br>        }            <br>        if(x==3){<br>            lcd.printf("                 ");<br>            lcd.locate(0,1);            <br>            lcd.printf("Done? - Press!! ");<br>            wait(0.05);<br>        }<br>                            <br>        //=================== Operations by Joystic ==========================<br>            <br>        //=================== press up<br>        if (Up){<br>            // limit for hour<br>            if(x==0){           <br>                if(y[0]&gt;11){<br>                    y[0]=0;<br>                    wait(0.5);<br>                }<br>            }<br>            // limit for minute<br>            if(x==1){<br>                if(y[1]&gt;58){<br>                    y[1]=0-1;<br>                    wait(0.5);<br>                }<br>            }<br>            // limit for seconds<br>            if(x==2){<br>                if(y[2]&gt;58){<br>                    y[2]=0-1;<br>                    wait(0.5);<br>                }<br>            }<br>                        <br>            if(y[0]!=12||y[1]!=60||y[2]!=60){                <br>                y[x]++;<br>                wait(0.5);<br>            }<br>        } // end if (up)               <br>                <br>        //=================== press down        <br>        if (Down){<br>            // limit for hour<br>            if(x==0){<br>                if(y[0]&lt;2){<br>                    y[0]=13;<br>                    wait(0.5);<br>                }<br>            }<br>            // limit for minute<br>            if(x==1){<br>                if(y[1]&lt;1){<br>                    y[1]=60;<br>                    wait(0.5);<br>                }<br>            }<br>            // limit for seconds<br>            if(x==2){<br>                if(y[2]&lt;1){                <br>                    y[2]=60;<br>                    wait(0.5);<br>                }<br>            }<br>                        <br>            if(y[0]!=0 || y[1]!=0 || y[2]!=0){            <br>                y[x]--;<br>                wait(0.5);<br>            }                    <br>        } // end if (down)<br>                <br>                <br>        //=================== press left    <br>        if (Left){<br>            if(x==0){                      <br>                x=3;<br>                wait(0.5);<br>            } // end if<br>                    <br>            else{<br>                x--;<br>                wait(0.5);<br>            } // end else<br>        } // end if (left)<br>                    <br>                <br>        //=================== press right   <br>        if (Right){<br>            if(x==3){<br>                x=0;<br>                wait(0.5);<br>            } // end if<br>                    <br>            else{<br>                x++;<br>                wait(0.5);<br>            } // end else<br>        } // end if (right)<br>                <br>                <br>        //=================== press joystic<br>        if(x==3){<br>            if(press==true){<br>                time(y[0], y[1], y[2]);<br>            }<br>        }                            <br>    } // end while loop<br>}<br><br><br>//==================================== set alarm function ============================================<br><br>void setAlarm(){<br>    int x=0;<br>    <br>    lcd.cls();<br>    <br>    while(1){<br>        lcd.locate(2,0);<br>        lcd.printf(" %d : %d : %d ",y[0],y[1],y[2]);          // locate time<br>        <br>        lcd.locate(0,1);                                // locate text<br>        <br>        // select array<br>        if(x==0){<br>            lcd.printf("                 ");<br>            lcd.locate(0,1);            <br>            lcd.printf("Hour");<br>            wait(0.05);<br>        }<br>        if(x==1){<br>            lcd.printf("                 ");<br>            lcd.locate(0,1);            <br>            lcd.printf("Minute");<br>            wait(0.05);<br>        }<br>        if(x==2){<br>            lcd.printf("                 ");<br>            lcd.locate(0,1);            <br>            lcd.printf("Second");<br>            wait(0.05);<br>        }            <br>        if(x==3){<br>            lcd.printf("                 ");<br>            lcd.locate(0,1);            <br>            lcd.printf("Done? - Press!! ");<br>            wait(0.05);<br>        }<br>        <br>        //=================== Operations by Joystic ==========================<br>                <br>        //=================== press up<br>        if (Up){<br>            // limit for hour<br>            if(x==0){           <br>                if(y[0]&gt;11){<br>                    y[0]=0;<br>                    wait(0.5);}<br>                }<br>            // limit for minute<br>            if(x==1){<br>                if(y[1]&gt;58){<br>                    y[1]=0-1;<br>                    wait(0.5);<br>                }<br>            }<br>            // limit for seconds<br>            if(x==2){<br>                if(y[2]&gt;58){<br>                    y[2]=0-1;<br>                    wait(0.5);<br>                }<br>            }<br>                        <br>            if(y[0]!=12||y[1]!=60||y[2]!=60){                <br>                y[x]++;<br>                wait(0.5);<br>            }<br>        } // end if (up)               <br>                <br>        //=================== press down        <br>        if (Down){<br>            // limit for hour<br>            if(x==0){<br>                if(y[0]&lt;2){<br>                    y[0]=13;<br>                    wait(0.5);<br>                }<br>            }<br>                <br>            // limit for minute<br>            if(x==1){<br>                if(y[1]&lt;1){<br>                    y[1]=60;<br>                    wait(0.5);<br>                }<br>            }<br>                <br>            // limit for seconds<br>            if(x==2){<br>                if(y[2]&lt;1){                <br>                    y[2]=60;<br>                    wait(0.5);<br>                }<br>            }<br>                            <br>            if(y[0]!=0 || y[1]!=0 || y[2]!=0){            <br>                y[x]--;<br>                wait(0.5);<br>            }                    <br>        } // end if (down)<br>                <br>        //=================== press left    <br>        if (Left){<br>            if(x==0){                      <br>                x=3;<br>                wait(0.5);<br>            } // end if<br>                        <br>            else{<br>                x--;<br>                wait(0.5);<br>            } // end else<br>        } // end if (left)<br>                            <br>        //=================== press right   <br>        if (Right){<br>            if(x==3){<br>                x=0;<br>                wait(0.5);<br>            } // end if<br>                        <br>            else{<br>                x++;<br>                wait(0.5);<br>            } // end else<br>        } // end if (right)<br>                        <br>        //=================== press joystic<br>        if(x==3){<br>            if(press==true){    <br>                for(int z=0;z&lt;3;z++){<br>                    alarm[z] = y[z];        // set array fot alarm<br>                }    <br>                setTime();<br>            }<br>        }<br>    }<br>}<br><br><br>//==================================== main function ============================================<br><br>int main() {<br>    // start program<br>    lcd.printf("-- Welcome --");<br>    wait(1);<br>    <br>    // main<br>    lcd.cls();<br>    lcd.locate(0,0);<br>    lcd.printf("Main Menu");<br>    wait(1);<br>    <br>    while(1){<br>        // wait for input from user - joy stick button<br>        int x;<br>        <br>        //=================== press up<br>        if (Up){                                 <br>            x=0;<br>     //       lcd.cls();<br>            lcd.locate(0,1);<br>            lcd.printf("%s", menu[x]);            <br>        } // end if (up)<br>                <br>        //=================== press down        <br>        if (Down){<br>            x=1;<br>      //      lcd.cls();<br>            lcd.locate(0,1);<br>            lcd.printf("%s", menu[x]);<br>        } // end if (down)<br>        <br>        //=================== press<br>        if(press){ <br>            if(x==0){<br>                setTime();<br>            }<br>            <br>            if(x==1){<br>                setAlarm();<br>            }<br>        }     <br>    } // end while loop<br>} // end main</div>]]></description>
         <enclosure url="" />
         <pubDate>2019-05-23 16:56:21 UTC</pubDate>
         <guid>https://padlet.com/khalish18/Coding/wish/363013550</guid>
      </item>
   </channel>
</rss>
