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
unsigned char tmpbuf[128]; | |
void light_condition_receiver(void); | |
void RxPacket(void); | |
void main(void) | |
{ | |
//hardware initialization... | |
if(P3_5) | |
{ |
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 "globalvar.h" // button2_time_cnt is defined in the header file | |
#include "function.h" | |
#define P3_5 1 // if P3_5 is 1, it will be the transmitter | |
#define period 1000 | |
unsigned char Packet_Tx[8]; // if initialize, this array will be a "constant", which can't be modified in code. | |
void WriteFIFO(void); | |
void WriteFIFO(void) |
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
unsigned short ADCbuffer; | |
unsigned short wc_DelayTimeOutCounter; | |
//skip the functions prototypes | |
void main(){ | |
//initiate hardware | |
//.. | |
//.. | |
while(1){ | |
if(wc_DelayTimeOutCounter==100){ // grab the value per second |
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
void ADC_Init(void); | |
void ADC_Init(){ | |
P0M=0x38;// set I/O as input/output mode | |
P0CON |= 0x02;//let P01 as a pure analog pin | |
P0UR=0;// disable the pull-high | |
ADM=0x81;// enable ADC function, and use AIN1 | |
ADR=0x60;// enable AIN channel, and set clock rate = fosc/1 |
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
void txsenddata(short); | |
char ch; | |
char chstring[]="Please type something to test: "; | |
void main(){ | |
for(int i=0; i<sizeof(chstring); i++) txsenddata(chstring[i]); | |
while(1){ | |
if(enableWrite){ | |
txsenddata(ch); | |
enableWrite=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
void UART_Init(void); | |
void txsenddata(short); | |
char rxreceivedata(void); | |
uint8_t enableWrite=0; | |
char ch; | |
char chstring[]="Please type something to test: "; | |
void main(){ | |
//initial function setting.. | |
for (int i=0; i<sizeof(chstring); i++) txsenddata(chstring[i]); |
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
enum{off, on, pwm} | |
sbit pwmOut = P0^1; | |
const int pwmValue=96;//120*0.8, which means 80% dutycycle | |
void PWM_Init(void); | |
void PWM(uint8_t status); | |
void PWM_Init(){ | |
T3YH=0x78;// 0-120 pieces | |
T3YL=0x00; |
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 <stdio.h> | |
#include <SN8F5701.H> | |
//variable | |
int count_millis=0; | |
uint8_t count_sec=0; | |
uint8_t count_min=0; | |
//prototype of functions | |
void Timer0_Init(void); |
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 <stdio.h> | |
#include <SN8F5701.H> | |
void Timer0_Init(void); | |
void main(){ | |
//initial function write down here, like the one "setup" function in Arduino | |
Timer0_Init(); | |
// | |
while(1){ | |
//just like the "loop" function in Arduino |
NewerOlder