Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About jrlane

  • Rank
  1. Just figured it out!!! My code works perfectly. The problem was how i had the switch hooked up. You should have the off position pull the input pin to ground, then pressing the switch should bring the pin high.... floating pins are a BAD IDEA.
  2. I'm beating my head against the wall trying to figure out what i thought would be a trivial task. Last night it took me longer than i expected to get the right configuration for my 16f88's just to flash some led's. Well i finally got that to work now i'm on to simply reading a switch and having a hell of a time. My connections are simple, Vdd and Vss, an led through a 200ohm resister from porta.0 to ground. I'm then using a 10k resister to connect Vdd to porta.1 to simulate a switch. What is happening is randomness. I have tried a few different examples on how to read a switch but they all seem to do the same thing, it seems to randomly blink the LED, and on occasion (at least it seems), blink when i connect the resister to input. Please lend me a hand fellas #include <system.h> #pragma DATA _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO #pragma DATA _CONFIG2, _IESO_OFF & _FCMEN_OFF #pragma CLOCK_FREQ 8000000 void main() { // Set up the Analog selection register ansel = 00000000b; // 1=Analog, 0=Digital RA1 as analog trisa = 00000010b; // 1=input, 0=output RA1 as input (for analog) trisb = 00000000b; porta=0; portb=0; osccon.6 = 1; osccon.5 = 1; osccon.4 = 1; while(1) { unsigned short timer = 0; // 16-bit variable while( porta.1 ); // wait for switch to be OFF while( !(porta.1) ); // wait for switch to be ON (pressed) // switch must be on.... delay_ms(100); // debounce while( porta.1 ) // loop until switch is released { delay_ms(10); timer++; } if( timer < 100 ) { porta.0=1; delay_ms(1000); porta.0=0; } else { porta.0=1; delay_ms(500); porta.0=0; delay_ms(500); porta.0=1; delay_ms(500); porta.0=0; } //porta.0=1; porta.7=1; //delay_ms(analog); delay_ms(analog); //porta.0=0; porta.7=0; //delay_ms(analog); delay_ms(analog); } }
  3. The Arduino compiler has this spiffy function called pulsein that gives you the pulse width of a pulse on a pin. What is the easiest way to accomplish this with boostc?
  • Create New...