📄 valve.c
字号:
#include <avr/io.h>
#include "valve.h"
#include "global.h"
void initValve()
{
//NOTE VERY IMPORTANT.
//For the initialize we set the PORTD register.
//But we mustn't open all the valve at the beginning.
//What will happen if we do so?
//All the chemical material flows into the garbage can!!!
PORTD = 0x00;
DDRD = 0xff;
//OK, shut up all valves!!!
setValveState(0, VALVE1_OFF | VALVE2_OFF | VALVE3_OFF | VALVE4_OFF);
}
void setValveState(unsigned char on, unsigned char mask)
{
if(on == 1)
{
PORTD &= mask;
}
else if(on == 0)
{
PORTD |= mask;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -