Page 110 - MDP2022-2
P. 110

char  datas[4];
                char  command_datas[4];

                void  command(int  data){
                    const  int  andMask[4]  =  {0x01,  0x02,  0x04,  0x08};
                    for(int  i  =  0;  i  <  4;  i++)
                        digitalWrite(5  -  i,  data  &  andMask[i]);
                    digitalWrite(6,  HIGH);
                    digitalWrite(6,  LOW);
                }

                void  readCommand(char  data){
                        switch(data){
                            case  'a'  :  command(9);  break;
                            case  'b'  :  command(10);  break;
                            case  'c'  :  command(11);  break;
                            case  'd'  :  command(12);  break;


                            case  'A'  :  command(1);  break;
                            case  'B'  :  command(2);  break;
                            case  'C'  :  command(3);  break;
                            case  'D'  :  command(4);  break;
                        }
                }
            }user;


            int  charToint(char*  charP){
                String  S_char(charP);
                memset(charP,  0,  5);
                return  S_char.toInt();
            }


            void  temp_moist(){
                float  h  =  dht.readHumidity();
                float  t  =  dht.readTemperature();

                if  (isnan(h)  ||  isnan(t))  {
                    Serial.println(F("Failed  to  read  from  DHT  sensor!"));
                    bluetooth.write("100  100");
                    return;
                }
                char  c_h[10];
                char  c_t[10];
                strcpy(c_h,  String(h,  2).c_str());
   105   106   107   108   109   110   111   112   113   114   115