Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
const int sensorPin = A0; const int outputPin = 9; const float upperThreshold = 75.0; const float lowerThreshold = 70.0; bool fanState = false; void setup() { pinMode(outputPin, OUTPUT); digitalWrite(outputPin, LOW); Serial.begin(9600); } void loop() { int sensorValue = analogRead(sensorPin); float temperature = (sensorValue * 5.0 / 1023.0) * 100.0; Serial.print("Temperature: "); Serial.println(temperature); if (temperature >= upperThreshold && !fanState) { digitalWrite(outputPin, HIGH); // Turn on fan/LED fanState = true; } else if (temperature <= lowerThreshold && fanState) { digitalWrite(outputPin, LOW); // Turn off fan/LED fanState = false; } delay(500); }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)