We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi Folks,
I have interfaced a DC motor and a keyboard with LPC2138, so that I can use the switches to control the direction of DC Motor. Here is the code which I used to perform the desired operation, but somehow this code is not responding. Can anyone please help me on this.
Here's the code :
#include<lpc21XX.h>
/*void Delay (int a) { int i; for (i=0;i<a*100;i++); }*/ int MotorDirection() {
int w; IO0SET = 0X000E0000; IO0CLR = 0X00010000; // Row 1 used w = IO1PIN & 0X00F00000; // Read the columns switch(w) {
case 0X00E00000 : IO1SET = 0X00050000; // Clk rotation of Motor return IO1SET;
case 0X00D00000 : IO1SET = 0X00060000; // AntiClk rotation of Motor return IO1SET;
case 0X00B00000 : IO1SET = 0X00050000; // Clkwise return IO1SET;
case 0X00700000 : IO1SET = 0X00060000; // AntiClkwise return IO1SET; } }
int main() {
IO1DIR = 0X00070000; // IN1=1.16,IN2=1.17,EN=1.18 - Output to L293D IO0DIR = 0X000F00000; // 0.16,0.17,0.18,0.19 as Rows & 0.20 - 0.23 as Columns
while(1)
{
MotorDirection();
}
I changed the code and was able to achieve what was expected. Thanks :D !!