reset()
[Main Functions]
void reset();Description
The reset() function will be called all the time when
the chip is powered down, use it to restore the initial state of the
chip, since CLanguage won’t erase the memory when the chip is powered
down.
Parameters
None.
Returns
Nothing.
Example Code
void setup() {
chipName("74HC163");
logicFamily(TTL);
pinLabel(1, "CLR", LINE_OVER);
pinLabel(2, "", CLOCK);
pinLabel(3, "A");
pinLabel(4, "B");
pinLabel(5, "C");
pinLabel(6, "D");
pinLabel(7, "ENP");
pinLabel(8, "GND");
groundPin(8);
pinLabel(9, "LOAD", LINE_OVER);
pinLabel(10, "ENT");
pinLabel(11, "QD");
pinMode(11, OUTPUT);
pinLabel(12, "QC");
pinMode(12, OUTPUT);
pinLabel(13, "QB");
pinMode(13, OUTPUT);
pinLabel(14, "QA");
pinMode(14, OUTPUT);
pinLabel(15, "RC0");
pinMode(15, OUTPUT);
pinLabel(16, "VCC");
powerPin(16);
}
bool lastCp = false;
int count = 0;
void loop() {
bool cp = digitalRead(2);
if (!lastCp && cp) {
if (!digitalRead(1))
count = 0;
else if (!digitalRead(9))
count = digitalReadNibble(3, 4, 5, 6);
else if (digitalRead(7) && digitalRead(10))
count = (count + 1) & 0x1F;
}
digitalWriteNibble(14, 13, 12, 11, count);
bool val = !(!digitalRead(11) && !digitalRead(12) && !digitalRead(13) && !digitalRead(14) && !digitalRead(10));
digitalWrite(15, val);
lastCp = cp;
}
void reset() {
// Reset the chip state
lastCp = false;
count = 0;
}