Show Posts
|
|
Pages: [1] 2
|
|
4
|
Using Arduino / Networking, Protocols, and Devices / Re: Two SPI on Arduino UNO?
|
on: June 13, 2012, 03:29:22 pm
|
I connect rfm70 and st7565r and I wrote program: #include <TouchScreen.h> #include <Dogm.h>
//Wireless---------------------------------------------------- #include "RFM70.h"
RFM70class RFM70; byte RFM70_buf[MAX_PACKET_LEN]; //RFM70 data buffer unsigned long RFMSendTime = 0; //next send time int RFMSendSpeed=1; //send packet every 1000 msec //------------------------------------------------------------ int a0Pin = PIN_A0_DEFAULT; Dogm dogm(7);
TouchScreen ts(3, 1, 0, 2); int s,t = 0; // s {10 - 100} t {5 - 55} int car_speed, car_turn = 0; //car_speed {5 - 95 } car_turn {3 - 53} int coords[2];
void setup(void){ Serial.begin(9600); dogm.setContrast(10); //Wireless---------------------------------------------------- RFM70.begin(); RFM70.Initialize(); RFMSendTime = millis(); //------------------------------------------------------------ pinMode(10, OUTPUT); pinMode(6, OUTPUT); }
void read_speed(){ if((coords[0] > 200) && (coords[0] < 800) && (coords[1] > 200) && (coords[1] < 815)) { Serial.print(", Speed:"); s = constrain(map(coords[0], 200, 800, 10, 100), 10, 100); t = constrain(map(coords[1], 200, 800, 5, 55), 5, 55); Serial.print(s); Serial.print(":"); Serial.println(t); } }
void draw(){ dogm.setHLine(20,110,30); //speed dogm.setVLine(65,8,55); // turn dogm.setVLine(120,0,63); dogm.setHLine(0,119,5); dogm.setHLine(0,119,60); //wykrywanie przeszkód /*if ( lewo == true ){ dogm.setBox(0,61,119,63); // góra , czyli przeszkoda po lewej } if (przodek == true){ dogm.setBox(121,0,127,63); } if ( prawo == true ) { dogm.setBox(0,0,119,4); } */ dogm.setBox(115 - s,58-t,125 - s,64-t);
} void loop(){ DOG_PGM_P p; // zczytanie z panelu ts.read(coords); Serial.print(coords[0]); Serial.print(","); Serial.println(coords[1]); // komunikacja [b]digitalWrite(10,LOW);[/b] dogm.start(); do{ digitalWrite(10,LOW); read_speed(); draw(); car_speed = 115 - s; //car_speed {5 - 95 } car_turn {3 - 53} car_turn = 58 - t; [b]digitalWrite(10,HIGH); [/b] [b] digitalWrite(6,LOW);[/b] rfmTask(); if (millis() > RFMSendTime) //send packet { RFMSendTime = millis() + RFMSendSpeed; RFM70_buf[0]=0X41; RFM70_buf[1]=0X42; RFM70_buf[2]=0X43; RFM70_buf[3]=0X44; RFM70.Send_Packet(WR_TX_PLOAD,RFM70_buf,3); } [b] digitalWrite(6,HIGH);[/b] } while (dogm.next() ); }
void rfmTask() //RFM70 event handler { if (RFM70.RfmInterrupt()) { if (RFM70.TxDataSentInterrupt()) { Serial.println("Data sent OK"); RFM70.SwitchToRxMode(); } if (RFM70.TxDataSentErrorInterrupt()) { Serial.println("Data sent error"); RFM70.SwitchToRxMode(); } } } On pin 10 i have chip select display, on pin 6 i have chip select RFM70. And only display working. I dont know what I doing wrong.
|
|
|
|
|
5
|
Using Arduino / Networking, Protocols, and Devices / Re: Two SPI on Arduino UNO?
|
on: June 13, 2012, 12:05:58 pm
|
|
Okey, I try change PIN_SS of st7565r but I have big problem. When I use deafult chip select pin (10) SCK is working normally when I changed PIN_SS to 5 SCK doesnt work(led diode stops blink).
I change values in dogm128.h in section #ifndef ADA_ST7565P_HW .
When I change only PIN_A0_DEFAULT to another I/O pin then it is working.
|
|
|
|
|
8
|
Using Arduino / Networking, Protocols, and Devices / Re: noob confuse with SPI - setSS() missing / RFM70 module
|
on: June 06, 2012, 09:35:50 am
|
Hello sbright33, here is the link to the library: skip.co.at/RFM70/RFM70.zipunpack it to C:\Program Files (x86)\arduino-1.0\libraries\RFM70. Pinout: CE Pin 9 CSN Pin 10 SCK Pin 13 MISO Pin 12 MOSI Pin 11 IRQ Pin 8 and don't forget the 3.3 V stepdown converter! Please ask me if you have any questions! Example code (not all was tested): #include "RFM70.h"
RFM70class RFM70;
byte RFM70_buf[MAX_PACKET_LEN]; //RFM70 data buffer unsigned long RFMSendTime = 0; //next send time int RFMSendSpeed=1000; //send packet every 1000 msec
void setup() { Serial.begin(57600); Serial.println("Arduino Start"); RFM70.begin(); RFM70.Initialize(); RFMSendTime = millis(); }
void loop() { rfmTask(); //check for RFM70 event in polling mode if (millis() > RFMSendTime) //send packet { RFMSendTime = millis() + RFMSendSpeed; RFM70_buf[0]=0X41; RFM70_buf[1]=0X42; RFM70_buf[2]=0X43; RFM70_buf[3]=0X44; RFM70.Send_Packet(WR_TX_PLOAD,RFM70_buf,4); Serial.println("Sending data"); } }
void rfmTask() //RFM70 event handler { if (RFM70.RfmInterrupt()) { if (RFM70.TxDataSentInterrupt()) { Serial.println("Data sent OK"); RFM70.SwitchToRxMode(); } if (RFM70.TxDataSentErrorInterrupt()) { Serial.println("Data sent error"); RFM70.SwitchToRxMode(); } if (RFM70.RxDataReadyInterrupt()) { Serial.println("Data received: "); byte rx_len = RFM70.Receive_Packet(RFM70_buf); if (rx_len) { for(byte i=1;i<rx_len;i++) { Serial.print(i); Serial.print("->"); Serial.println(RFM70_buf[i]); } } } } }
This is code for transmitting? How recive? I have 2 arduino's and 2 rfm70 mnodule.
|
|
|
|
|