Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ipst.h>
- #include "ipst.h"
- #include "ipst_gp2d120_lib.h"
- float Humidity;
- float Temperature;
- float HIN;
- int TempAnalog;
- int ValueBluetooth;
- int force;
- int UV;
- int adcValue;
- int Gass;
- void setup()
- {
- setTextSize(2);
- setTextColor(GLCD_YELLOW);
- setTextColor(GLCD_SKY);
- glcd(1, 1, "IPST-SE");
- glcd(2, 1, "MicroBOX");
- setTextSize(1);
- setTextColor(GLCD_PINK);
- glcd(7, 2, "Sensor Station");
- }
- void loop()
- {
- if (uart1_available())
- ValueBluetooth = uart1_getkey();
- if (ValueBluetooth == 1) {
- TempAnalog = analog(1);
- if (TempAnalog < 340) {
- Temperature = (-5.0 + (TempAnalog - 120.0)) / (240) * ( 15.0 + 5.0 ) + 3.5;
- setFloatPrecision(2);
- uart1("%f", Temperature);
- }
- else if (TempAnalog < 500)
- {
- Temperature = (15.0 + (TempAnalog - 340.0)) / (240) * (30 + 15.0) + 3.5;
- setFloatPrecision(2);
- uart1("%f", Temperature);
- }
- else if (TempAnalog < 660)
- {
- Temperature = (30.0 + (TempAnalog - 500.0)) / (160) * (50 + 30) + 3.5;
- setFloatPrecision(2);
- uart1("%f", Temperature);
- }
- else {
- Temperature = (50.0 + (TempAnalog - 660.0)) / (130) * (75 + 50) + 3.5;
- setFloatPrecision(2);
- uart1("%f", Temperature);
- }
- delay(1000);
- }
- if (ValueBluetooth == 2)
- {
- UV = analogRead(2);
- if (UV < 10)
- {
- uart1("%d", 0);
- }
- else if (UV >= 10 && UV < 46)
- {
- uart1("%d", 1);
- }
- else if (UV >= 46 && UV < 65)
- {
- uart1("%d", 2);
- }
- else if (UV >= 65 && UV < 83)
- {
- uart1("%d", 3);
- }
- else if (UV >= 83 && UV < 103)
- {
- uart1("%d", 4);
- }
- else if (UV >= 103 && UV < 124)
- {
- uart1("%d", 5);
- }
- else if (UV >= 124 && UV < 142)
- {
- uart1("%d", 6);
- }
- else if (UV >= 142 && UV < 162)
- {
- uart1("%d", 7);
- }
- else if (UV >= 162 && UV < 180)
- {
- uart1("%d", 8);
- }
- else if (UV >= 180 && UV < 200)
- {
- uart1("%d", 9);
- }
- else if (UV >= 200 && UV < 221)
- {
- uart1("%d", 10);
- }
- else if (UV >= 221 && UV < 240)
- {
- uart1("%d", 11);
- }
- delay(1000);
- }
- if (ValueBluetooth == 3)
- {
- uart1("%d", getdist(A3));
- delay(1000);
- }
- if (ValueBluetooth == 4)
- {
- HIN = analog(4) / 204.6;
- Humidity = (HIN - 0.958) / 0.0307;
- setFloatPrecision(2);
- uart1("%f", Humidity);
- delay(1000);
- }
- if (ValueBluetooth == 5)
- {
- Gass = analogRead(5); //Read Gas value from analog 5
- delay(100);
- if (Gass < 300)
- {
- out (15, 1);
- }
- else
- {
- out (15, 0);
- }
- uart1("%d", Gass);
- delay(1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement