인터넷에서 돌아다니는 전자파 측정기(?)라고 하는걸 시험삼아 만들어보려고 했는데 계속 업로드가 안되네요ㅠㅠ
아두이노:1.8.13 (Windows Store 1.8.42.0) (Windows 10), 보드:"Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"
스케치는 프로그램 저장 공간 11538 바이트(35%)를 사용. 최대 32256 바이트.
전역 변수는 동적 메모리 333바이트(16%)를 사용, 1715바이트의 지역변수가 남음. 최대는 2048 바이트.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x3e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x3e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x3e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x3e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x3e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x3e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x3e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x3e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x3e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x3e
보드에 업로딩중에 문제 발생. 다음을 참고하세요. http://www.arduino.cc/en/Guide/Troubleshooting#upload
이 리포트는 파일 -> 환경설정에 "컴파일중 자세한 출력보이기"를
활성화하여 더 많은 정보를
보이게 할 수 있습니다.
이런 식으로요
코드는
#include <U8glib.h>
#define VERSION_STR "Ver: 1.0 (191221)"
U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); /* OLED-091 */
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); /* Graphic Library for 0.96" */
/* PIN MAP */
int PIN_EMF_DETECT = A0;
int PIN_LED = 11;
int PIN_BUZZER = 5;
//#define DEBUG 1
#define NUMREADINGS 15 // raise this number to increase data smoothing
#define DELAY(ms) {int kk=0; while(kk++<ms){delayMicroseconds(1000);}}
const char *gageStr[] = {
"-", /* 0 */
"#",
"##",
"###",
"####",
"#####",
"######",
"#######",
"########",
"#########",
"##########"
};
int senseLimit = 15; // raise this number to decrease sensitivity (up to 1023 max)
//CHANGE THIS TO affect the speed of the updates for numbers. Lower the number the faster it updates.
int updateTime = 40;
int emfData = 0; // reading from probePin
int rawData = 0; // reading from probePin
int mapData = 0;
int levelData = 0;
void beepSound(int times)
{
analogWrite(PIN_BUZZER, 20); /* for PASSIVE Buzzer */
//digitalWrite(PIN_BUZZER, HIGH); /* for ACTIVE Buzzer */
for (int ii = 0; ii < times; ii++) {
DELAY(ii * 100 + 30);
}
analogWrite(PIN_BUZZER, LOW);
DELAY(30);
}
void drawLogo(void)
{
beepSound(2);
u8g.firstPage();
do {
u8g.setFont(u8g_font_10x20);
u8g.drawStr(2, 25, "EMF DETECTOR");
} while ( u8g.nextPage() );
delay(1000);
beepSound(2);
u8g.firstPage();
do {
u8g.setFont(u8g_font_10x20);
u8g.drawStr(2, 25, " HooneyPaPa ");
} while ( u8g.nextPage() );
delay(1000);
beepSound(2);
u8g.firstPage();
do {
u8g.setFont(u8g_font_7x14);
u8g.drawStr(2, 25, VERSION_STR);
} while ( u8g.nextPage() );
delay(2000);
}
/*
Display Info
*/
void drawInfo(void) {
u8g.firstPage();
do {
u8g.setFont(u8g_font_7x14);
u8g.drawStr(1, 13, "LVL :");
u8g.drawStr(42, 13, gageStr[levelData]);
u8g.drawStr(1, 32, "EMF :");
u8g.setPrintPos(40, 32);
u8g.print(emfData);
} while ( u8g.nextPage() );
}
void setup() {
drawLogo();
#if defined(DEBUG)
Serial.begin(9600);
#endif
}
void probeEMF()
{
int ii;
for ( ii = 0, rawData = 0; ii < NUMREADINGS; ii++ )
rawData += analogRead(PIN_EMF_DETECT);
rawData /= NUMREADINGS;
levelData =
(rawData >= 0 && rawData < 50) ? 0 :
(rawData >= 50 && rawData < 150) ? 1 :
(rawData >= 150 && rawData < 250) ? 2 :
(rawData >= 250 && rawData < 350) ? 3 :
(rawData >= 350 && rawData < 450) ? 4 :
(rawData >= 450 && rawData < 550) ? 5 :
(rawData >= 550 && rawData < 650) ? 6 :
(rawData >= 650 && rawData < 750) ? 7 :
(rawData >= 750 && rawData < 850) ? 8 :
(rawData >= 850 && rawData < 950) ? 9 : 10;
emfData = rawData;
rawData = constrain(rawData, 0, senseLimit);
mapData = map(rawData, 1, senseLimit, 1, 1023);
if (rawData) {
analogWrite(PIN_LED, mapData);
if ( rawData > 10 )
analogWrite(PIN_BUZZER, rawData / 2);
}
else {
analogWrite(PIN_LED, 0);
analogWrite(PIN_BUZZER, 0);
}
#ifdef DEBUG
Serial.println("---------------------------------------------------");
Serial.print("rawData : "); Serial.println(rawData);
Serial.print("emfData : "); Serial.println(emfData);
Serial.print("levelData : "); Serial.println(levelData);
#endif
}
void loop() {
drawInfo();
probeEMF();
delay(updateTime);
}
이렇게 됩니다.
|