#include
#include
using namespace std;
int main()
{
bool a = true; //bool a = 1;
bool b = false; //bool b = false;
cout << "a = " << a << endl;
cout << "b = " << b << endl;
}
/*
* Uno pin{0,1} for UART, should not be used
*/
#define TOTAL_PIN 18
char SW[] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
char SW_Pressed( char swno );
char s[50];
//---------------------------------------------------------
void loop() { //
static int i = 2;
if ( SW_Pressed( SW[i] )) {
sprintf( s, "SW%d Pressed\n", SW[i] );
Serial.print( s );
}
if ( ++i >= 18 ) i = 2;
}
void setup() {
Serial.begin(115200);
Serial.print( "\n Hello World \n" );
}
//-------------------------------------------------------
// 瘥?30mS瑼X1甈?
char SW_Pressed( char swno ) {
#define dT 30 //mS
static long inited = 0; //Is every bit initialized? 0/1:n/y
static long bHiVolt=-1, old = 0;
char rc = false; //?身? false(瘝??)
if ( !(inited & 1L<
inited = inited | 1L<
pinMode( inited , INPUT_PULLUP);
}
if ( millis() - old >= dT ) {
digitalWrite( swno, HIGH );//?踹?瘚格???圈隤方???
if ( !digitalRead( swno ) ) {
if ( bHiVolt & (1L<
bHiVolt &= ~(1L<
rc = true;
old = millis(); //???菔◤??嚗??脣?????
}
} else {
bHiVolt |= 1L<
}
}
return rc;
}
//-------------------------------------------------------