Author Topic: coding help  (Read 1310 times)

Offline lilronney

  • Guppy
  • *
  • Posts: 1
  • Post quality +0/-0
coding help
« on: January 04, 2013, 02:22:48 AM »
   
hey can someone help me get a better understanding of how coding on a controller works i understand how to hook up the pic into the controller but how do u know what to write for each i/o line im trying to start to learn how to code but im lost about how to integrate this into a controller for instance with drop shot on call of duty which can be done with the controller by dropping 1st then aiming just not as fast so what im basically wondering is does the code basically just control a sequence of buttons designed to work when only 1 button is pressed any help would greatly appreciated

Offline RDC

  • Administrator
  • Around the block
  • *
  • Posts: 2609
  • Post quality +90/-2
  • Gender: Male
  • The CGnome Project
Re: coding help
« Reply #1 on: January 05, 2013, 08:48:19 PM »
It really depends on the controller and how it functions, you need to break out the DMM and figure that kind of thing out, or look it up.

The CG/2/3 version boards all have Common Ground buttons, so all you do is drive the IO line of the PIC connected to the button line of the controller Lo to make that function happen.

For example: If you take the typical 12F683 and wire it up so the GPIO1 pin is connected to the A button line, then code it to make that IO line go Hi (pause 1 second) Lo (pause 1 second) Hi, etc, etc forever..

Code: [Select]
while(1)
{
GP1_bit = 1;
delay_ms(1000);
GP1_bit = 0;
delay_ms(1000);
}

.. then it will sit there the same as you pressing the A button manually over and over and over again.


The Triggers in the CG/2/3 however are Analog, and need to be driven Hi (1.5v) to fire, but the IO lines of the PIC there must be configured as inputs (hi Z, TRI-Stated) when not being used by the PIC so the Triggers can function normally.

If you can make LEDs blink by turning the Cathodes (grounds) to them on/off, then you can do any of the 16 buttons in the CG version controllers, since grounding LED Cathode = LED on, is the same thing as grounding button line in controller = button pressed.


Screwing up is one of the best learning tools, so long as the only thing you're not learning is how to screw up.

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.5 © 2008-2012, SimplePortal