FAQFAQ   GalleryGallery   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   Forum RSS Feed   Hacked Gadgets Main Site 

Microcontroller Programming

 
Post new topic   Reply to topic    Hacked Gadgets Forum Index -> Microcontroller Resources
View previous topic :: View next topic  
Author Message
cookiemonster
Newbie


Joined: 04 Jan 2012
Posts: 1
Location: Middle Earth

PostPosted: Wed Jan 04, 2012 6:22 pm    Post subject: Microcontroller Programming Reply with quote

Hi guys, I have been interested in programming microcontrollers for a little while now. I have done a ton of reading on microcontrollers, using the programming language C. So I started a project that uses a microcontroller to output a signal to the circuit board of an Xbox 360 controller, and is activated by a few buttons. The short version, I am making a rapid fire mod for the controller. I thought it would prove an interesting first project. I have the basics down, but want feedback on my code that I am planning to write to the PIC 16F505. If you could get me as much feedback/constructive criticism as possible it would be greatly appreciated.
Here is the code. I also thought it would be helpful to include a very basic pin input picture. I am almost positive it contains a lot of errors, and it's certainly not the most efficient code.

void main() {
ANSEL = 0x00; // Configure all ports with analog function as digital
//Changing ports to digital
ANSELH = 1;
TRISC4 = 1;
TRISC3 = 1;
TRISC2 = 1; //setting the IO's to inputs and outputs
TRISC5 = 0;
TRISC0 = 1;
TRISB2 = 0;

unsigned char x = PORTC2;
unsigned char y = PORTC4; //setting the variables
unsigned char a = PORTC3;
int k;
start:;
if((x == 1)& y == 1){ //if both buttons are pressed then preform if statement
while (1){
PORTB2 = 1; // loob the b2 over and over
delay_us(4); // make port b2 high for 4 microseconds
while (1){
PORTC5 = 1; // make port c5 high delay 1 sec. This blinks the led.
delay_ms(1000);

}
}
}
if ((x ==1) & a == 1){
while (1){
for (k=1; k<3; k++){ // loops the port b2 three times
PORTB2 = 1;
delay_us(4);
} delay_ms(200);

while (1){
PORTC5 = 1; // if both buttons are pressed then preform if statement
delay_ms(500); // make port c5 high, delay 1/2 seconds. This blinks the led.

}
}
}
goto start;
}

[img]http://s1094.photobucket.com/albums/i457/n0bby01/?action=view&current=RapidFireMod.jpg

If the picture doesn't work just follow this URL

http://s1094.photobucket.com/albums/i457/n0bby01/?action=view&current=RapidFireMod.jpg
_________________
I like cookies.
Back to top
View user's profile Send private message

Display posts from previous:   
Post new topic   Reply to topic    Hacked Gadgets Forum Index -> Microcontroller Resources All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group