Skip to content

Instantly share code, notes, and snippets.

int pinValue=A0;//declaring analog pin as pinValue
void setup() {
Serial.begin(9600);//setting baud rate to 9600
pinMode(4,OUTPUT);//declaring GPIO4 as output
}
void loop() {
int x=analogRead(pinValue);//taking values from the sensor to the variable x
Serial.println(x);//printing the sensor value onto the serial monitor
delay(500);
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
const char* ssid = "YourNetworkName";
const char* password = "YourNetworkPassword";
const char* mqttServer = "m11.cloudmqtt.com";
const int mqttPort = 12948; //your port number
const char* mqttUser = "YourMqttUser";
const char* mqttPassword = "YourMqttUserPassword";
#include <ESP8266WiFi.h>
const char* ssid = "Network";
const char* password = "nononono";
int wifiStatus;
void setup() {
Serial.begin(9600);
#include <EEPROM.h>
void setup()
{
Serial.begin(9600);
uint addr = 0;
struct {
uint val = 0;
// defines pins numbers
const int trigPin = 2; //D4
const int echoPin = 0; //D3
// defines variables
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
#include <ESP8266WiFi.h>
#include "DHT.h" // DHT11 temperature and humidity sensor Predefined library
#define DHTTYPE DHT11 // DHT 11
#define dht_dpin 0 //GPIO-0 D3 pin of nodemcu
const char* ssid = "Your SSID";
const char* password = "Your Wifi Password";
int ldr = A0; //Analog pin from LDR
int ledPin=11; //Digital Pin to LED
int ldrValue;
void setup() {
pinMode(ldr,INPUT);
pinMode(ledPin,OUTPUT);
Serial.begin(9600); //Start the Serial communication and set rate to 9600
}
float temp;                                                               //Declare temp variable of type float
int tempPin =A 0;                                     //The analog pin of  LM35 is connected to this analog input pin of Arduino, here it is connected to A0
void setup()
{
Serial.begin(9600);                                              //Sets data rate for serial transmission between the Arduino and the computer
const int ledPin = 13;const int ldrPin = A0;void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);
}