This file contains 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
int interruptPin_A = 2; // หลัง | |
int interruptPin_B = 3; // ก่อน | |
uint32_t _timeA, _timeB, _timeC, _timeD, dt; | |
uint8_t print_dt; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(115200); | |
attachInterrupt(digitalPinToInterrupt(interruptPin_A), interruptPin_A_change, CHANGE); |
This file contains 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 <Wire.h> | |
#include <SPI.h> | |
////////////////////////////////////////////////// | |
double sum=0; | |
int count=0; | |
int pulsewidth = 0; | |
double frequency ; |
This file contains 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
typedef struct | |
{ | |
__IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ | |
__IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ | |
__IO uint32_t SMCR; /*!< TIM slave Mode Control register, Address offset: 0x08 */ | |
__IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ | |
__IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ | |
__IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ | |
__IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ | |
__IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ |
This file contains 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 <Wire.h> | |
#include <DS1307.h> | |
DS1307 clock; | |
RTCDateTime dt; | |
void setup() | |
{ | |
Serial.begin(9600); | |
// Initialize DS1307 | |
Serial.println("Initialize DS1307");; | |
clock.begin(); |
This file contains 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 <SoftwareSerial9.h> | |
#define MOSI 11 | |
#define MISO 12 | |
#define TX MOSI | |
#define RX MISO | |
#define LEDPIN 13 | |
SoftwareSerial9 mySerial(RX, TX); |
This file contains 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
#define addr_IR_command_1 1 | |
#define addr_IR_command_2 127 | |
#define addr_IR_command_3 253 | |
#define addr_IR_command_4 379 | |
uint16_t addr_command[] = {addr_IR_command_1, addr_IR_command_2, addr_IR_command_3, addr_IR_command_4}; | |
typedef struct protocol_pattern { | |
float ir_freq = 0; |
This file contains 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
/* Wasin Wongkum */ | |
/* | |
SD card attached to SPI bus as follows: | |
UNO: MOSI - pin 11, MISO - pin 12, CLK - pin 13, CS - pin 4 (CS pin can be changed) | |
i2c: A4(SDA), A5(SCL) | |
hi_wheel/low_wheel/hi_Roller/low_Roller | |
*/ | |
#define I2c_addr 0x01 |
This file contains 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
/*-------------------ramp---------------------------------*/ | |
if(angle < max_ramp_angle) angle += max_ramp_angle*50/ramp_time; | |
servo.write(angle); | |
/*-------------------ramp---------------------------------*/ | |
/*-------------------pulse---------------------------------*/ | |
if(time_now > pulse_stop_time ) { | |
servo.write(low_angle); |
This file contains 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
/** | |
****************************************************************************** | |
* File Name : main.c | |
* Description : Main program body | |
****************************************************************************** | |
* | |
* COPYRIGHT(c) 2016 STMicroelectronics | |
* | |
* Redistribution and use in source and binary forms, with or without modification, | |
* are permitted provided that the following conditions are met: |
This file contains 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 <Wire.h> | |
#include <LiquidCrystal_I2C.h> | |
// Set the LCD address to 0x27 for a 16 chars and 2 line display | |
LiquidCrystal_I2C lcd(0x20, 20, 4); | |
uint32_t time_1 = 0; | |
uint32_t time_2 = 0; | |
int newspeed; | |
void a_found() { | |
time_1 = micros(); |