Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include <Adafruit_NeoPixel.h>
  2. #include <OneWire.h>
  3. #include <DallasTemperature.h>
  4. #include <Adafruit_GFX.h>
  5. #include <Adafruit_ILI9341.h>
  6. #include <SPI.h>
  7. #include <Timers.h>
  8. #define MS9700 A0
  9. #define TFT_DC 9
  10. #define TFT_CS 10
  11. float temp;
  12. Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
  13. Timer  oiltt; //timer czujnika oleju
  14. Timer  watertt; //timer czujnika wody
  15.  
  16. OneWire oneWire(A5); // ds18b20 podłączenie do A5
  17. DallasTemperature sensors(&oneWire); //Przekazania informacji do biblioteki
  18. Adafruit_NeoPixel rpmled = Adafruit_NeoPixel(16, A0, NEO_GRB + NEO_KHZ800);
  19.  
  20. void setup() {
  21.  Serial.begin(9600);
  22.  analogReference(EXTERNAL);
  23.  sensors.begin(); //Inicjalizacja czujnikow
  24.  rpmled.begin(); //Inicjalizacja paska led
  25.  tft.begin(); //inicjalizacja LCD
  26.  oiltt.begin(1000);
  27.  watertt.begin(750);
  28. }
  29.  
  30. void loop() {
  31.   oiltemp();
  32.   watertemp();
  33. }
  34.  
  35. void oiltemp(){//MCP9700
  36.    if (oiltt.available())
  37.   {
  38.      int sensorValue = analogRead(MS9700); // pomiar temperatury
  39.      float temp = sensorValue * (0)*3.3/1024.0;
  40.     oiltt.restart();
  41.   }
  42.   tft.print("Oil:");
  43.   tft.setCursor(220, 150); //ustalenie pozycji
  44.   tft.print(temp);
  45. }
  46.  
  47. void watertemp(){ //ds18b20
  48.    if (watertt.available())
  49.    {
  50.     sensors.requestTemperatures(); //pomiar temperatury
  51.     watertt.restart();
  52.  }
  53.    tft.print("Water:");
  54.    tft.setCursor(5, 20); //ustalenie pozycji
  55.    tft.print(sensors.getTempCByIndex(0));
  56. }
  57. //void rpm() //16LED
  58. //void oilpress()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement