Skip to content

Instantly share code, notes, and snippets.

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <Ultrasonic.h>
#define LED D0 // Led in NodeMCU at pin GPIO16 (D0).
// Set these to run example.
#define FIREBASE_HOST "garagecardetector.firebaseio.com"
#define FIREBASE_AUTH "TuJmJEc1YJRAOtEEiS1qYxYE2KiqRDaWNkGxyLhm"//change with your Database secrets
@gresan-gits
gresan-gits / main.c
Created February 2, 2020 10:33
CCS C IO
#include <main.h>
#include <output.c>
int8 in;
void main ()
{
output_float (pin_D7) ;
//Example blinking LED program
while (true)
{
@gresan-gits
gresan-gits / code.c
Created February 2, 2020 10:48
CCS RS232
#include <18F4520.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz FOR PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used FOR I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(clock=12000000)
#use rs232(FORCE_SW,baud=4800,parity=N,xmit=PIN_B3,rcv=PIN_B4,bits=8,stream=UART_MEM,errors)
@gresan-gits
gresan-gits / main.c
Created February 2, 2020 11:02
CCS C ADC
#include <main.h>
#use rs232(UART1,baud=9600,parity=N,stream=UART,errors)
INT16 value, value2;
float vol;
void test(){
float a=5;
float b=1024;
float v=(float)a/b;
@gresan-gits
gresan-gits / main.c
Last active February 2, 2020 11:09
CCS C LCD16x2
#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>
@gresan-gits
gresan-gits / ext.c
Created February 2, 2020 11:20
CCS C INT
#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++)
{
@gresan-gits
gresan-gits / main.c
Created February 2, 2020 11:28
CCS C Timer
#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)
@gresan-gits
gresan-gits / main.c
Created February 2, 2020 11:41
CCS C PWM
#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)
@gresan-gits
gresan-gits / ds18b20.h
Created February 2, 2020 14:18
CCS C DS18B20
/*** FILEHEADER ****************************************************************
*
* FILENAME: ds1820.h
* DATE: 25.02.2005
* AUTHOR: Christian Stadler
*
* DESCRIPTION: Driver for DS1820 1-Wire Temperature sensor (Dallas)
*
******************************************************************************/
@gresan-gits
gresan-gits / main.c
Last active February 3, 2020 08:33
CCS C DC Servo SG90
#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