/* UART */
Serial.begin(BPR); //bit per rate set (in main)
Serial.available(); //check serial data ex> if(Serial.avilable());
Serial.read(); //read data ex> abc=Serial.read();
Serial.println; //text sent
Serial.print(A,Type); //A=num, Type=DEC, HEX, OCT, BIN
//ex> Serial.print('A'); text
/* PWM Set */
int led=9; //PWM PIN_Number
void setup(){
pinMode(led,OUTPUT);
}
void loop(){
analogWrite(led, pNum);// led=pinnumber, pNum=duty PWM Put
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
delay(30);
}
/* ADC Set */
int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read
void setup(){
Serial.begin(9600); // setup serial
}
void loop(){
val = analogRead(analogPin); // read the input pin (0 to 5)
Serial.println(val); // debug value
}
/* SW push read */
int pushButton = 2;
void setup() {
Serial.begin(9600);
pinMode(pushButton, INPUT);
}
void loop() {
int buttonState = digitalRead(pushButton); // read the input pin:
Serial.println(buttonState); // print out the state of the button:
delay(1);
}
'Study > Arduino' 카테고리의 다른 글
4-Digit Display header file (0) | 2014.09.15 |
---|---|
Grove-LCD RGB Backlight header file (0) | 2014.09.15 |
SW체터링 소프트웨어적 해결 (0) | 2014.09.05 |
Arduino LED Control (0) | 2014.09.02 |
Arduino PWM Control (0) | 2014.08.30 |