Skip to content

Instantly share code, notes, and snippets.

View maxpromer's full-sized avatar

Max maxpromer

View GitHub Profile
/*
* Codeing By IOXhop : www.ioxhop.com
*/
#define OUT_PIN A0
void setup() {
Serial.begin(9600);
}
/*
* Codeing By IOXhop : www.ioxhop.com
*/
#define Trig_PIN 12
#define Echo_PIN 13
void setup() {
pinMode(Trig_PIN, OUTPUT);
pinMode(Echo_PIN, INPUT);
/*
* File: main.c
* Author: max30012540@hotmail.com
*
* Created on 3/18/2017 8:09:13 AM UTC
* "Created in MPLAB Xpress"
* Full code you can see : https://mplabxpress.microchip.com/mplabcloud/example/details/306
*/
unsigned long __pulseIn(int pin, int lavel) {
while(digitalRead(pin) != lavel) ;
unsigned long time_s = 0;
while(digitalRead(pin) == lavel) {
delayMicroseconds(1);
time_s++;
}
return time_s;
}
/*
* Codeing By IOXhop : www.ioxhop.com
*/
#include <SoftwareSerial.h>;
#define TX_PIN 2 // Pin connect to Tx
#define RX_PIN 3 // Pin connect to Rx
SoftwareSerial mySerial(RX_PIN, TX_PIN); // Rx, Tx
// Coding By IOXhop : www.ioxhop.com
#include <Servo.h>
Servo myservo;
#define UNLOCK_POS 5
#define LOCK_POS 100
void setup() {
// Coding By IOXhop : www.ioxhop.com
#include <Servo.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#define UNLOCK_POS 5
#define LOCK_POS 100
#include <HLW8012.h>
#define SERIAL_BAUDRATE 9600
// GPIOs
#define SEL_PIN 11
#define CF1_PIN 13
#define CF_PIN 12
// Check values every 2 seconds
int sensorPin = 3;
int indicator = 13;
void setup() {
pinMode(sensorPin, INPUT);
pinMode(indicator, OUTPUT);
Serial.begin(9600);
}
void loop() {
#include <Wire.h>
#define BH1750_ADDR 0x23
int readBH1750(byte dev_addr) {
Wire.beginTransmission(dev_addr);
Wire.write(0x10);
if (Wire.endTransmission() != 0) return -1;
delay(200);
Wire.requestFrom((int)dev_addr, 2);