Question: code (the code seems to work but can't properly program the breadboard I can't tell what's wrong with it) //TEJ3M mainWritePort.c /********************************************************************* This program flashes


code (the code seems to work but can't properly program the breadboard I can't tell what's wrong with it)
//TEJ3M mainWritePort.c
/*********************************************************************
This program flashes the LED?s connected to your PIC a specified number of times
Hardware Notes:
* PIC24F32KA302 operating at 8MHz
Outputs:
* RB4:RB11
********************************************************************/
/*******************************************************************
Include Files
********************************************************************/
#include "p24F32ka302.h"
#include "configBits.h"
#include "delay.h"
/*******************************************************************
Symbolic Constants used by main()
********************************************************************/
//delay constant name ? set your time in milliseconds
#define SHORT_DELAY 250
/*******************************************************************
Local Function Prototypes
********************************************************************/
void initTimer (void);
void delay (unsigned long milli);
void forward (void);
void backward (void);
void turnLeft (void);
void turnRight (void);
/*******************************************************************
Global Variable Declarations
********************************************************************/
/*******************************************************************
main() function
********************************************************************/
int main (void)
{
//initialize peripherals
initTimer();
//PORTB all outputs
TRISB=0;
TRISA=1;
// initialize PORTB
LATB=0;
ANSA=1;
while(1)
{
forward();
delay(5000);
backward();
delay(5000);
turnLeft();
delay(5000);
turnRight();
delay(5000);
}
} //end mainWritePort
/*******************************************************************
List of Functions
********************************************************************/
void forward () {
LATBbits.LATB2 = 1;
LATBbits.LATB3 = 0;
LATBbits.LATB4 = 1;
LATBbits.LATB5 = 0;
}
void backward () {
LATBbits.LATB2 = 0;
LATBbits.LATB3 = 1;
LATBbits.LATB4 = 0;
LATBbits.LATB5 = 1;
}
void turnLeft () {
LATBbits.LATB2 = 1;
LATBbits.LATB3 = 0;
LATBbits.LATB4 = 0;
LATBbits.LATB5 = 1;
}
void turnRight() {
LATBbits.LATB2 = 0;
LATBbits.LATB3 = 1;
LATBbits.LATB4 = 1;
LATBbits.LATB5 = 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
