This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int ledPin = 16; | |
const int ledPin2 = 17; | |
const int ledPin3 = 5; | |
// setting PWM properties | |
const int freq = 5000; | |
const int ledChannel = 0; | |
const int resolution = 8; | |
void setup() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//**************************************************************// | |
// Name : 16Relay control via MQTT // | |
// Author : Son Bui-Mualinhkien.vn // | |
// Date : 23 March, 2016 // | |
// Version : 1.0 // | |
// Notes : Code for using a 74HC595 Shift Register // | |
// : Change Maximum packet size on pubsubclient lib to 512 bytes | |
// : https://play.google.com/store/apps/details?id=org.ngoinhaso.app.mqtthomecontrol //App UI | |
//**************************************************************// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ex_usb_common.h> | |
#define MPU_SDA PIN_E0 | |
#define MPU_SCL PIN_E1 | |
#use I2C(master, sda=MPU_SDA, scl=MPU_SCL) | |
#use TIMER(TIMER=1, TICK=1ms, BITS=16, NOISR) | |
#define RAD_TO_DEG 180/PI | |
#define LCD_ENABLE_PIN PIN_D2 | |
#define LCD_RS_PIN PIN_D0 | |
#define LCD_RW_PIN PIN_D1 | |
#define LCD_DATA4 PIN_D4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#use spi(FORCE_HW,master,baud = 10000000, BITS=8,MSB_FIRST, stream = RFID, ENABLE_ACTIVE=0)// uses hardware SPI and gives this stream the name SPI_STREAM | |
//MF522 Command word | |
#define PCD_IDLE 0x00 //NO action; Cancel the current command | |
#define PCD_AUTHENT 0x0E //Authentication Key | |
#define PCD_RECEIVE 0x08 //Receive Data | |
#define PCD_TRANSMIT 0x04 //Transmit data | |
#define PCD_TRANSCEIVE 0x0C //Transmit and receive data, | |
#define PCD_RESETPHASE 0x0F //Reset | |
#define PCD_CALCCRC 0x03 //CRC Calculate | |
// Mifare_One card command word |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <16F877A.h> | |
#device ADC=10 | |
#FUSES NOWDT //No Watch Dog Timer | |
#FUSES NOBROWNOUT //No brownout reset | |
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used FOR I/O | |
#use delay(crystal=12MHz) | |
#define LED PIN_C1 | |
#define DELAY 10 | |
#define RC PIN_E0 | |
#define LCD_ENABLE_PIN PIN_D2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** FILEHEADER **************************************************************** | |
* | |
* FILENAME: ds1820.h | |
* DATE: 25.02.2005 | |
* AUTHOR: Christian Stadler | |
* | |
* DESCRIPTION: Driver for DS1820 1-Wire Temperature sensor (Dallas) | |
* | |
******************************************************************************/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <main.h> | |
/* | |
Cach tinh gia tri dutu thong qua set value | |
8bit value = period+1*duty_cycle | |
16bit value= 4*(period+1)*duty_cycle | |
*/ | |
void main() | |
{ | |
setup_timer_2(T2_DIV_BY_4,124,1); //100 us overflow, 100 us interrupt//Khoi tao timer 2 tao tan so pwm(10k) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "main.h" | |
#define LED PIN_C0 | |
#int_TIMER0 | |
void Ngat_TIMER0(void) | |
{ | |
fprintf(PORT1,"Ngat timer 0\r\n"); | |
} | |
#int_TIMER1 | |
void Ngat_TIMER1(void) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ext.h> | |
#define LED_BAO PIN_D0 | |
#define LED_NGAT PIN_D1 | |
#INT_EXT //chi thi khai bao ngat(Chuong trinh se thuc hien ham ngay sau chi thi) | |
void ngatngoai0_isr(VOID) //ham thuch hien khi co ngat | |
{ | |
fprintf (DEBUG_PORT, "\r\nBat dau thuc hien ham trong ngat"); | |
output_toggle (LED_NGAT); | |
for (INT i = 0; i < 10; i++) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <main.h> | |
#define LCD_ENABLE_PIN PIN_B0 | |
#define LCD_RS_PIN PIN_B1 | |
#define LCD_RW_PIN PIN_B2 | |
#define LCD_DATA4 PIN_B4 | |
#define LCD_DATA5 PIN_B5 | |
#define LCD_DATA6 PIN_B6 | |
#define LCD_DATA7 PIN_B7 | |
#include <lcd.c> |