User Tools

Site Tools


arduino:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
arduino:start [2022/03/01 15:40] – created illuarduino:start [2022/03/03 11:36] (current) – removed illu
Line 1: Line 1:
-<code c> 
-//PINS 
-#define REEDSWITCH 13 
-#define WHEELSIZE 0.91 
  
-volatile unsigned long rotations = 0; 
-float meter = 0.0; 
-volatile unsigned long lastactive = 0; 
- 
-// Debounce Vars 
-volatile unsigned long last_micros; 
-unsigned long debouncing_time = 500;              //Debouncing Time in Milliseconds 
- 
-void setup() 
-{ 
-  // Reed Sensor (Interrupt)  
-  attachInterrupt(digitalPinToInterrupt(REEDSWITCH), debounceInterrupt, FALLING); 
-  //PINS 
-  pinMode(REEDSWITCH, INPUT); 
-  lastactive = millis(); 
-} 
- 
-void loop() 
- 
-  if ( rotations >= 1 && ((millis() - lastactive) >= 1500) ) { 
-    meter = rotations * WHEELSIZE;  
-    // rotations = 0;                       
-    // meter = 0; 
-  } 
-} 
- 
-// ----- Helper Functions  
-void debounceInterrupt() { 
-  if ( micros() < last_micros ) { 
-    last_micros = micros(); 
-  } 
-  if ((unsigned long)(micros() - last_micros) >= debouncing_time * 1000) { 
-    rotations++; 
-    last_micros = micros();  
-    lastactive = millis(); 
-  } 
-} 
-  </pre></code></p> 
- 
-</main> 
- 
-<main role="main" class="container"> 
-  <h2 id="dht22" class="mt-3">DHT22</h2> 
-  <p> <code><pre> 
-#include "DHTesp.h" 
- 
-DHTesp dht; 
- 
-void setup() 
-{ 
-  Serial.begin(115200); 
-  Serial.println(); 
-  Serial.println("Status\tHumidity (%)\tTemperature (C)\t(F)\tHeatIndex (C)\t(F)"); 
- 
-  dht.setup(12); // data pin 2 
-} 
- 
-void loop() 
-{ 
-  delay(dht.getMinimumSamplingPeriod()); 
- 
-  float humidity = dht.getHumidity(); 
-  float temperature = dht.getTemperature(); 
- 
-  Serial.print(dht.getStatusString()); 
-  Serial.print("\t"); 
-  Serial.print(humidity, 1); 
-  Serial.print("\t\t"); 
-  Serial.print(temperature, 1); 
-  Serial.print("\t\t"); 
-  Serial.print(dht.toFahrenheit(temperature), 1); 
-  Serial.print("\t\t"); 
-  Serial.print(dht.computeHeatIndex(temperature, humidity, false), 1); 
-  Serial.print("\t\t"); 
-  Serial.println(dht.computeHeatIndex(dht.toFahrenheit(temperature), humidity, true), 1); 
-} 
- 
-  </pre></code></p> 
- 
-</main> 
- 
-<main role="main" class="container"> 
-  <h2 id="webserver" class="mt-3">Webserver</h2> 
-  <p> <code><pre> 
-#include < ESP8266WiFi.h> 
-#include < WiFiClient.h> 
-#include < ESP8266WebServer.h> 
-  
-// Replace with your network credentials 
-const char* ssid = "Your WiFI SSID"; 
-const char* password = "Your WiFI Password"; 
-  
-ESP8266WebServer server(80);   //instantiate server at port 80 (http port) 
-  
-String page = ""; 
- 
-void setup(void){ 
-  
-  delay(1000); 
-  Serial.begin(115200); 
-  WiFi.begin(ssid, password); //begin WiFi connection 
-  Serial.println(""); 
-   
-  // Wait for connection 
-  while (WiFi.status() != WL_CONNECTED) { 
-    delay(500); 
-    Serial.print("."); 
-  } 
-  Serial.println(""); 
-  Serial.print("Connected to "); 
-  Serial.println(ssid); 
-  Serial.print("IP address: "); 
-  Serial.println(WiFi.localIP()); 
-  server.on("/", [](){ 
-    page = "ESP8266 Webserver - hello world!"; 
-    server.send(200, "text/html", page); 
-  }); 
-   
-  server.begin(); 
-  Serial.println("Web server started!"); 
-} 
-  
-void loop(void){ 
-  server.handleClient(); 
- 
-</code> 
arduino/start.1646145619.txt.gz · Last modified: 2022/03/01 15:40 by illu