Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
#define DHTPIN 13 // Pin connected to the DHT11 sensor
#define DHTTYPE DHT11 // Type of the sensor
DHT dht(DHTPIN, DHTTYPE);
// Array to store the segments for displaying digits 0-9
const byte segments[10] = {
B11111100, // 0
B01100000, // 1
B11011010, // 2
B11110010, // 3
B01100110, // 4
B10110110, // 5
B10111110, // 6
B11100000, // 7
B11111110, // 8
B11110110 // 9
};
// Pins connected to the segments of the display
const int segmentPins[7] = {3, 4, 5, 6, 7, 8, 9};
void setup() {
// Start communication with the temperature sensor
Serial.begin(9600);
dht.begin();
// Initialize the display pins as outputs
for (int i = 0; i < 7; i++) {
pinMode(segmentPins[i], OUTPUT);
}
}
void loop() {
// Read temperature and humidity from the DHT11 sensor
float temperatureC = dht.readTemperature();
float humidity = dht.readHumidity();
// Display temperature and humidity on 7-segment display
displayTemperature(temperatureC);
displayHumidity(humidity);
// Print temperature and humidity to serial monitor
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.print(" °C, Humidity: ");
Serial.print(humidity);
Serial.println(" %");
delay(2000); // Wait for a short duration
}
void displayDigit(int digit, int value) {
// Turn off all segments
for (int i = 0; i < 7; i++) {
digitalWrite(segmentPins[i], LOW);
}
// Turn on segments based on the value to display
byte segmentsToDisplay = segments[value];
for (int i = 0; i < 7; i++) {
digitalWrite(segmentPins[i], bitRead(segmentsToDisplay, i));
}
// Enable the corresponding digit
digitalWrite(segmentPins[digit], HIGH);
}
void displayTemperature(float tempC) {
int tempInt = int(tempC);
int tensDigit = tempInt / 10; // Get the tens digit
int onesDigit = tempInt % 10; // Get the ones digit
// Display digits on the 7-segment display
displayDigit(1, tensDigit); // Display tens digit on the leftmost segment
displayDigit(0, onesDigit); // Display ones digit on the rightmost segment
}
void displayHumidity(float humidity) {
// Convert humidity to integer
int humidityInt = int(humidity);
int tensDigit = humidityInt / 10; // Get the tens digit
int onesDigit = humidityInt % 10; // Get the ones digit
// Display digits on the 7-segment display
displayDigit(5, tensDigit); // Display tens digit on the leftmost segment
displayDigit(4, onesDigit); // Display ones digit on the rightmost segment
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team