Skip to content

Commit

Permalink
update pinreadwrite with new pinWrite() function
Browse files Browse the repository at this point in the history
we needed to add a new function pinWrite().
  • Loading branch information
RichardChambers committed Jan 6, 2018
1 parent 6f5b2df commit 8da21b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions project11/pinreadwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ void pinWriteHiLo (int iPin, int iCount, int iDelayHigh, int iDelayLow)
{
for ( ; iCount > 0; iCount--) {
digitalWrite (iPin, HIGH);
delay (iDelayHigh);
if (iDelayHigh > 0) delay (iDelayHigh);
digitalWrite (iPin, LOW);
delay (iDelayLow);
if (iDelayLow > 0) delay (iDelayLow);
}
digitalWrite (iPin, LOW);
}
Expand All @@ -24,13 +24,17 @@ void pinWriteLoHi (int iPin, int iCount, int iDelayLow, int iDelayHigh)
{
for ( ; iCount > 0; iCount--) {
digitalWrite (iPin, LOW);
delay (iDelayHigh);
if (iDelayLow > 0) delay (iDelayLow);
digitalWrite (iPin, HIGH);
delay (iDelayLow);
if (iDelayHigh > 0) delay (iDelayHigh);
}
digitalWrite (iPin, HIGH);
}

void pinWrite (int iPin, int iLevel)
{
digitalWrite (iPin, ((iLevel > 0) ? HIGH : LOW));
}

int pinRead (int iPin)
{
Expand Down
2 changes: 2 additions & 0 deletions project11/pinreadwrite.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// the pin to the specified level, HIGH or LOW, for its initial conditions.
void pinSetupWrite (int iPin, int iLevel);

void pinWrite (int iPin, int iLevel);

// for the number of times specified by the value of iCount, vary
// the signal level of the specified pin.
// These two functions have a loop where the output level of the pin
Expand Down

0 comments on commit 8da21b2

Please sign in to comment.