hanzo/DigitalReadSerialX8.cpp

35 lines
764 B
C++
Raw Normal View History

2013-02-26 00:35:19 +09:00
/*
DigitalReadSerialX8.cpp
(C)2013 kou029w - MIT License
*/
#if defined(ARDUINO) && ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
#include "DigitalReadSerialX8.h"
template<>
void DigitalReadSerialX8(HardwareSerial& serial, uint8_t minPin);
#ifdef __AVR_ATmega32U4__
template<>
void DigitalReadSerialX8(Serial_& serial, uint8_t minPin);
#endif
template<typename T>
void DigitalReadSerialX8(T& serial, uint8_t minPin=12){
if(!serial) return;
for(int i=minPin; i<minPin+8; i++){
pinMode(i, INPUT);
}
serial.println("Press any key to end.");
delay(1000);
while(serial.available() == 0){
for(int i=minPin; i<minPin+8; i++){
serial.print('\t');
serial.print(digitalRead(i));
}
serial.print('\n');
}
}