基板図
部品面(部品挿入なし)
部品面(部品挿入)
ハンダ面
ケース内配線
動作確認中
テスト用ブレッドボード配線図
基板設計でミスってArduinoのピン(D2、D4~D6)を1つずらしてしまいました。
幸いArduinoのスケッチを変更することで対応できました。
Github:
https://github.com/ryood/Arduino_EG
/* * Arduino EG * * 2018.07.10 * */ #define UART_TRACE (0) #define PIN_CHECK (0) #define TITLE_STR1 ("Arduino EG") #define TITLE_STR2 ("20180710") const int ThresholdPin = 0; const int GateInPin = 2; const int AttackPin = 4; const int InvAttackPin = 5; const int GateOutPin = 6; const int LedPin = 13; #if (PIN_CHECK) const int CheckPin = 10; #endif enum EG_STATE { ST_ATTACK, ST_DECAY, ST_RELEASE }; volatile enum EG_STATE state = ST_RELEASE; void GateIn() { bool isGateOn = digitalRead(GateInPin); #if (UART_TRACE) Serial.println(isGateOn); #endif if (isGateOn) { state = ST_ATTACK; digitalWrite(LedPin, HIGH); } else { state = ST_RELEASE; digitalWrite(LedPin, LOW); } } void setup() { pinMode(AttackPin, OUTPUT); pinMode(InvAttackPin, OUTPUT); pinMode(GateOutPin, OUTPUT); pinMode(LedPin, OUTPUT); pinMode(GateInPin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(GateInPin), GateIn, CHANGE); #if (PIN_CHECK) pinMode(CheckPin, OUTPUT); #endif #if (UART_TRACE) Serial.begin(115200); Serial.println(TITLE_STR1); Serial.println(TITLE_STR2); delay(1000); #endif } void loop() { int th = analogRead(ThresholdPin); if (state == ST_ATTACK && th > 683) { state = ST_DECAY; } #if (UART_TRACE) Serial.print(th); Serial.print("\t"); Serial.println(state); #endif switch (state) { case ST_ATTACK: digitalWrite(GateOutPin, HIGH); digitalWrite(InvAttackPin, LOW); digitalWrite(AttackPin, HIGH); break; case ST_DECAY: digitalWrite(AttackPin, LOW); digitalWrite(InvAttackPin, HIGH); break; case ST_RELEASE: digitalWrite(AttackPin, LOW); digitalWrite(GateOutPin, LOW); break; } }
/* * Arduino EG Charge Test * * 2018.07.05 * */ #define TITLE_STR1 ("Arduino EG Charge Test") #define TITLE_STR2 ("20180705") const int ThresholdPin = 0; const int GateInPin = 2; const int GateOutPin = 4; const int DischargePin = 5; const int CheckPin = 7; volatile bool isGateOn = false; void GateIn() { isGateOn = !digitalRead(GateInPin); //Serial.println(isGateOn); if (isGateOn) { // GateOutPin digitalWrite(GateOutPin, HIGH); // DischaregePin pinMode(DischargePin, INPUT); // Hi-Z } else { // GateOutPin digitalWrite(GateOutPin, LOW); // DischaregePin pinMode(DischargePin, OUTPUT); digitalWrite(DischargePin, LOW); // Sink } } void setup() { pinMode(GateOutPin, OUTPUT); pinMode(DischargePin, INPUT); // Hi-Z pinMode(GateInPin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(GateInPin), GateIn, CHANGE); pinMode(CheckPin, OUTPUT); Serial.begin(115200); Serial.println(TITLE_STR1); Serial.println(TITLE_STR2); delay(1000); } void loop() { int th = analogRead(ThresholdPin); Serial.println(th); if (isGateOn && th < 683) { digitalWrite(CheckPin, HIGH); } else { digitalWrite(CheckPin, LOW); } }