aurdino programming.......... need help

hey... i m new to aurdino programming, i m trying this simple code

define SS 10

define MOSI 11

define MISO 12

define SCK 13

define pinMode(SCK_PIN, OUTPUT)

define pinMode(MOSI_PIN, OUTPUT)

define pinMode(MISO_PIN, INPUT)

define pinMode(SS_PIN, OUTPUT)

void setup() { Serial.bgin(9600); digitalWrite(SS_PIN,LOW); if (SS_PIN == LOW) { Serial.println ("low enabled"); } elseif (SS_PIN == HIGH) { Serial.println("problem");

} void loop () { }

i get no output on serial monitor....

am i supposed to insert some delay??? or is there any other issue??? kindly help

Serial.bgin(9600);

Spelling.

hey... i m new to aurdino programming, i m trying this simple code

define SS 10

define MOSI 11

define MISO 12

define SCK 13

define pinMode(SCK_PIN, OUTPUT)

define pinMode(MOSI_PIN, OUTPUT)

define pinMode(MISO_PIN, INPUT)

define pinMode(SS_PIN, OUTPUT)

void setup() { Serial.bgin(9600); digitalWrite(SS_PIN,LOW); if (SS_PIN == LOW) { Serial.println ("low enabled"); } elseif (SS_PIN == HIGH) { Serial.println("problem");

} void loop () { }

i get no output on serial monitor....

am i supposed to insert some delay??? or is there any other issue??? kindly help

sorry i misspelled........ its correctly spelled in the original program checked it

#define SS_PIN 10
#define MOSI_PIN 11
#define MISO_PIN 12
#define SCK_PIN 13

void setup()
{
  pinMode(SCK_PIN, OUTPUT);
  pinMode(MOSI_PIN, OUTPUT);
  pinMode(MISO_PIN, INPUT);
  pinMode(SS_PIN, OUTPUT);
  Serial.begin(9600);
  digitalWrite(SS_PIN,LOW);
  if (digitalRead(SS_PIN) == LOW) Serial.println ("low enabled"); else Serial.println("problem");
}
void loop ()
{
}

thank you thank you… problem solved !!!

actually i m using the aurdino board to control the cc1101 ic using SPI…
i m trying to write to its configuration registers…

so here is the code

#include <ELECHOUSE_CC1101.h>
#define SS 10
#define MOSI 11
#define MISO 12
#define SCK 13

#define pinMode(SCK_PIN, OUTPUT)
#define pinMode(MOSI_PIN, OUTPUT)
#define pinMode(MISO_PIN, INPUT)
#define pinMode(SS_PIN, OUTPUT)

byte s;
void setup ()
{
Serial.begin(9600);
ELECHOUSE_cc1101.Init();
s= ELECHOUSE_cc1101.SpiReadReg(CC1101_FREQ0);
Serial.println (s);
}
void loop()
{
}

using this code i get 0 where as i m writing 0x62 in FREQ0 register… i m using Elechouse library files… if u can help in this matter… i can provide the code files as well

Hi

Firstly, it's always best to use the code tags here - makes your inserted code so much more readable.

I've not tried your code, but there's a few issues. I don't think it would compile since it will still need another } to conclude the setup() function, SS_PIN is undefined, and the elseif...but that aside let's look at your logic.

if (SS_PIN == LOW)
{
Serial.println ("low enabled");
}
else if (SS_PIN == HIGH)
{ 
Serial.println("problem");
}

(space and extra } added).

Presuming SS_PIN is defined at the top of your code as 10 and that SS should be SS_PIN, that value never gets changed. Specifically, anything in a #DEFINE is actually just substituted as text in-line before the compiler does its work, so it isn't a variable that can be changed, but that probably doesn't matter for what I think you're trying to achieve.

Presently what's happening in your code is you've set digital IO pin number 10 as output, subsequently tell the Arduino to pull that pin low with a digitalWrite(), and then test to see if SS_PIN which is inserted by the compiler as the value 10, is either 0 (the mathematical value that equates to low) or 1 (the actual mathematical value representing high) which it will never be since 10 will always remain 10.

If you want to test the state of that IO pin you could use digitalRead() on it and test the value of that. I suspect that's what you intended too.

if (digitalRead(SS_PIN) == LOW) {
Serial.println ("low enabled");
}

For bonus points, understanding LOW is the same as 0 and the same as false also means you can shortcut the above test to: if(!digitalRead(SS_PIN) Serial.println("low enabled");But now I've typed that I know that may just cause confusion, so maybe ignore it until you get this current logic settled.

Hope this helped, Geoff

thnkxxxxxxxx 4 the help ........ i got this issue solved....... thnkxxx : :)

could you help me in serially interfacing aurdino with cc1101??

I downloaded the code examples from elechouse. Put the .cpp and .h files in a subfolder under 'libraries'. The example send and receive progs would work ?....without the additioan code you made. I guess you dont need to do those defines to get i working.

HS_HS: could you help me in serially interfacing aurdino with cc1101??

Give it a go yourself, and when you get stuck, put the details in the forum and you'll often find people who can help.

All the best with your project, Geoff

i put the header and the cpp file in library…

beside i just made a code to read one of the config registers… ie FREQ0
here is the code

#include <ELECHOUSE_CC1101.h>
byte s;
void setup ()
{
Serial.begin (9600);
ELECHOUSE_cc1101.Init();
s= ELECHOUSE_cc1101.SpiReadReg(CC1101_FREQ0);
Serial.println(s);
}
void loop ()
{}

but it is returning me 0 every time :frowning:

i did......... i have already placed it on the forum.... actually i need an urgent help

here is where i need a help

i m using elechouse library files…

i m trying to read the value of the configuration register FREQ0

here is the code

#include <ELECHOUSE_CC1101.h>
byte s;
void setup ()
{
Serial.begin (9600);
ELECHOUSE_cc1101.Init();
s= ELECHOUSE_cc1101.SpiReadReg(CC1101_FREQ0);
Serial.println(s);
}
void loop ()
{}

but this returns me 0 everytime… where as i set its value as 0x62… can some 1 help plxxx???

At what point does this code set the value to 0x62 ?

when we call the function ELECHOUSE_Init() this function goes to elechouse.cpp...... this is the function

void ELECHOUSE_CC1101::Init(void) { SpiInit(); //spi initialization GDO_Set(); //GDO set digitalWrite(SS_PIN, HIGH); digitalWrite(SCK_PIN, HIGH); digitalWrite(MOSI_PIN, LOW); Reset(); //CC1101 reset RegConfigSettings(); //CC1101 register config SpiWriteBurstReg(CC1101_PATABLE,PaTabel,8); //CC1101 PATABLE config } the RegConfigSettings() function configures the register and sets this value

plxxxxxxxxxx i require urgentttttttt help :(

the setup() function only run once after the board reset.
it’s like

setup(); // run only once
loop();
loop();
loop();
loop();
... // loop() foh ehh-vah!

so I think you want to put your codes inside the loop() function instead of setup(), so your arduino will continuesly read the data and spit them to the Serial.

tried it as welll bt now its continuously returning me 0...... :0

Wow now these threads are all merged this reads very confused.

Please post your code as it currently is, inside CODE tags (the # button gives you these) so we can see where you're up to now.

yeah this has got messsy…

######################## code here################################

#include <ELECHOUSE_CC1101.h>
byte s;
void setup ()
{
Serial.begin (9600);
ELECHOUSE_cc1101.Init();
s= ELECHOUSE_cc1101.SpiReadReg(CC1101_FREQ0); //trying to read the configuration register
Serial.println(s);
}
void loop ()
{}

#################################

i m using elechouse library files as mentioned before

From mthe manual..

Define CCxxx0_FREQ2 0x0D / / Frequency control word, high INT8U

Define CCxxx0_FREQ1 0x0E / / Frequency control word, middle INT8U

Define CCxxx0_FREQ0 0x0F / / Frequency control word, low INT8U

Serial.println (ELECHOUSE_cc1101.SpiReadReg(15)); // prints out ctrl-reg lowbyte Try also the other two registers (14 and 13) I guess thay shall not all return 0