Skip to content

Instantly share code, notes, and snippets.

View WillFK's full-sized avatar

William Fernandes Koehler WillFK

View GitHub Profile
/**
* playing the imperial march with a buzzer. got the tabs from here: https://gist.github.com/tagliati/1804108
*
*/
#include "pitches.h"
int PIN_BUZZER = 9;
// eH -> NOTE_E5
int PIN_BUZZER = 9;
void setup() {
Serial.begin(9600);
pinMode(PIN_BUZZER, OUTPUT);
}
void loop() {
analogWrite(PIN_BUZZER, 255);
delay(1);
int PIN_LED = 9;
int PIN_INPUT = 2;
int pirState = 0;
void setup() {
Serial.begin(9600);
pinMode(PIN_LED, OUTPUT);
pinMode(PIN_INPUT, INPUT);
}
int PIN_LED = 9;
int brightness = 0;
int fadeAmount = 5;
void setup() {
pinMode(PIN_LED, OUTPUT);
Serial.begin(9600);
}
void loop() {
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1);
}
int PIN_LED = 13;
int PIN_PUSH_BUTTON = 2;
void setup() {
Serial.begin(9600);
pinMode(PIN_PUSH_BUTTON, INPUT);
}
void loop() {
int buttonState = digitalRead(PIN_PUSH_BUTTON);
int PIN_LED = 13;
int pin_state = 0;
void setup() {
// put your setup code here, to run once:
}
void loop() {
pin_state = (pin_state + 1) % 2;
int ledPin = 13; // LED
int pirPin = 2; // PIR Out pin
int pirStat = 0; // PIR status
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(pirPin, INPUT);
Serial.begin(9600);
}
void loop(){
pirStat = digitalRead(pirPin);
/*
* created by Rui Santos, https://randomnerdtutorials.com
*
* Complete Guide for Ultrasonic Sensor HC-SR04
*
Ultrasonic sensor Pins:
VCC: +5VDC
Trig : Trigger (INPUT) - Pin11
Echo: Echo (OUTPUT) - Pin 12
GND: GND
const int pwm = 3 ; //initializing pin 2 as pwm
const int in_1 = 8 ;
const int in_2 = 9 ;
//For providing logic to L298 IC to choose the direction of the DC motor
void setup()
{
pinMode(pwm,OUTPUT) ; //we have to set PWM pin as output
pinMode(in_1,OUTPUT) ; //Logic pins are also set as output