Hello, I'm requesting help to design and implement an Arduino C/C++ program to count each LOW to HIGH transition occurring in a train of pulses (generated by a NE555 timer). When each transition occurs, the count will be displayed in the bank of 8 LEDs (in a row on the breadboard all connected to digital pins on the Arduino Mega 2560). All the wiring is correct, it's just the code I need some help with. I haven't coded much in many years and I've never been the best at it, though I do need it to finish this small project. I know it shouldn't be very hard to do. Any help is appreciated.
Extra info:
1. By setting up GPIO pin #2 as an input pin, you can read the logic state (HIGH or LOW) of the pulse train
generated by the NE555 timer circuit.
2. Using a polling loop, detect when a LOW to HIGH transition takes place and, when it does, increment an 8-bit
counter. The counter is not to be incremented any other time. As transitions are counted, it’s okay for the
counter MSB (Most Significant Bit) to carry out into the “bit bucket” and the count start over at zero again.
3. Whenever the counter is incremented, the 8-bit count should be displayed in the group of 8 LEDs on your utility
breadboard.
So, when started, the binary value displayed in the LED bank should increment every time a LOW to HIGH transition
occurs. (The rightmost LED displays the counter LSB and the leftmost LED displays the counter MSB.) Since the
transitions occur approximately once every two seconds, the value displayed in the LEDs should increment
approximately every two seconds.
I can give more information if I can. From my code, you'll see I haven't done too much yet.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <CSCI_LED.h>
#include <CSCI_GPIO.h>
#include <CSCI_Pushbutton.h>
#include <CSCI_Console.h>
#include <CSCI_SysUtils.h>
const uint8_t *PortDirPtr = &DDRL;
const uint8_t *PortDataPtr = &PORTL;
const int LedOnState = LOW;
const int LedOffState = HIGH;
// GPIO input pin no 2
const int PulsePin = 2
// GPIO input pin for pushbutton "A"
const int PinButtonA = 52;
// LED pin numbers on arduino mega 2560
const int BitToPin[8] = { 49, 48, 47, 46, 45, 44, 43, 42 };
void setup() {
}
void loop() {
}
|