|
|
View previous topic :: View next topic |
Author |
Message |
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Mon Apr 17, 2017 2:51 pm |
|
|
Could also just use some of the RN modules (I think the RN-131 comes to mind) from Microchip.
has Analog and GPIO -- all over WiFi (or Bluetooth and I think Xigbee) if you wanted. _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Apr 17, 2017 2:59 pm |
|
|
Yeesh, I just looked up those rn-131 chips from Digikey.ca....about $50 ! and of course you need some 'other stuff' to make them work...my simple, easy solution is to use HC-12 modules for $6 each, as I pointed out 2 pages ago...once the 'RS232 code is running (PIC to PIC), simply add the HC-12s and the project is finished.
Jay |
|
|
sergio3214
Joined: 15 Mar 2017 Posts: 25 Location: brasil
|
adc via rf |
Posted: Mon Apr 17, 2017 3:57 pm |
|
|
Good night ...
I'll use the HC12 module
But the question is and how can I improve this code to make it work with RS 232 communication? Is open for suggestions.
Code: | #include<16f628a.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Clock <=4Mhz
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#use delay(clock=4000000) // clock internal
#use rs232(baud=9600, xmit=PIN_B2,rcv=PIN_B1)
#define RF_OUTPUT PIN_B1 // O receptor RF é conectado
#define RF_INPUT PIN_B2 // O Transmissor RF é conectado
#define botao_incremento PIN_B0
#define botao_decremento PIN_B4
#define botao_start PIN_A3
#define led_ligado PIN_A2
int cont,ligado,tempo;
void main()
{
setup_ccp1(CCP_OFF);
setup_timer_2(T2_DIV_BY_4,249,1);
setup_vref(FALSE);
ligado=0;
cont=0;
tempo=10;
while (true)
{
// botão start
if ((input(botao_start)) && (ligado==0))
{
output_high(led_ligado);
ligado=1;
while (input(botao_start)){};
delay_ms(tempo);
}
if ((input(botao_start)) && (ligado==1))
{
output_low(led_ligado);
ligado=0;
cont=0;
while (input(botao_start)){};
delay_ms(tempo);
}
// botão incremento
if ((input(botao_incremento)) && (ligado==1))
{
if ((cont>=0) && (cont<=249))
{
cont++;
}
if (cont>=249)
{
cont=249;
}
delay_ms(tempo);
}
// botão decremento
if ((input(botao_decremento) && (ligado==1)))
{
if ((cont>=1) && (cont<=249))
{
cont--;
}
if (cont<=0)
{
cont=0;
}
delay_ms(tempo);
}
// Controle do PWM
if (ligado==1)
{
set_pwm1_duty(cont);
}
if (ligado==0)
{
set_pwm1_duty(0);
}
}
} |
|
|
|
|
|
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
|