Skip to content

Instantly share code, notes, and snippets.

View iotguider's full-sized avatar

Iotguider iotguider

View GitHub Profile
@iotguider
iotguider / Interfacing_Vibration_Switch_Module_KY-002_in_Arduino.ino
Created December 2, 2017 06:25
Code for interfacing Vibration Switch Module KY-002 in Arduino
int Led = 13 ;// define LED Interface
int vibration = 2; // define the vibration sensor interface
int val; // define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ; // define LED as output interface
pinMode (vibration, INPUT) ; // output interface defines vibration sensor
}
@iotguider
iotguider / Small_Microphone_Sound_Detection_Module_KY-038_in_Raspberry_Pi.py
Created November 29, 2017 15:41
Code for Small Microphone Sound Detection Module KY-038 in Raspberry Pi
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
#GPIO SETUP
sound = 17
led = 27
GPIO.setmode(GPIO.BCM)
GPIO.setup(sound, GPIO.IN)
GPIO.setup(led,GPIO.OUT)
@iotguider
iotguider / Advanced_web_server_with_Flask_in_Raspberry_Pi_Python.py
Created November 25, 2017 14:03
Code for Advanced web server with Flask in Raspberry Pi Python
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello world'
@app.route('/<name>')
def hello(name):
@iotguider
iotguider / Python_web_application_with_Flask_in_Raspberry_Pi.py
Last active November 25, 2017 14:01
Code for Python web application with Flask in Raspberry Pi
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello world'
@app.route('/iotguider')
def index():
@iotguider
iotguider / Sample_Python_web_application_with_Flask_in_Raspberry_Pi.py
Created November 22, 2017 17:18
Code for Sample Python web application with Flask in Raspberry Pi
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello world'
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
@iotguider
iotguider / Small_Microphone_Sound_Detection_Module_KY-038_in_Arduino.ino
Created November 18, 2017 06:26
Code for Small Microphone Sound Detection Module KY-038 in Arduino
int led=13;
int soundPin=7;
boolean val =0;
void setup(){
pinMode(led, OUTPUT);
pinMode(soundPin, INPUT);
Serial.begin (9600);
}
@iotguider
iotguider / Interfacing_Tilt_Switch_Module_in_Raspberry_Pi.py
Created November 12, 2017 12:11
Code for Interfacing Tilt Switch Module in Raspberry Pi
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
# The input pin of the Sensor will be declared. Additional to that the pullup resistor will be activated
tiltpin = 27
ledpin = 17
GPIO.setup(tiltpin, GPIO.IN)
GPIO.setup(ledpin,GPIO.OUT)
@iotguider
iotguider / Interfacing_Tilt_Switch_Module_in_Arduino.ino
Created November 9, 2017 13:14
Code for interfacing Tilt Switch Module in Arduino
const int LED = 13;
const int TiltSwitch = 2;
int val = 0; //Initialize value to zero.
void setup() {
pinMode (LED,OUTPUT); //Initialize LED pin.
pinMode (TiltSwitch,INPUT); //Initialize Tilt Switch pin.
Serial.begin(9600);
}
void loop() {
val = digitalRead(TiltSwitch); //Store sensor value in variable.
@iotguider
iotguider / Interfacing_7_Color_LED_Flash_module_KY-034_in_Raspberry_Pi.py
Last active November 6, 2017 10:26
Code for Interfacing 7 color LED Flash module KY-034 in Raspberry Pi
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(17,GPIO.OUT)
while True:
GPIO.out(17, GPIO.HIGH)
time.sleep(1)
GPIO.out(17, GPIO.LOW)
time.sleep(1)
@iotguider
iotguider / Interfacing_7_Color_LED_Flash_module_KY-034_in_Arduino.ino
Created November 3, 2017 17:09
Code for Interfacing 7 Color LED Flash module KY-034 in Arduino
void setup () {
// Initialize the digital pin as an output.
// Pin 11 has an LED connected on most Arduino boards:
pinMode (11, OUTPUT);
}
void loop () {
digitalWrite (11, HIGH); // set the LED on
delay (2000); // wait for a second
digitalWrite (11, LOW); // set the LED off