Recent Posts

Pages: 1 2 [3] 4 5 ... 10
22
Programming Questions / Re: Will it work?
Last post by Robin2 - Today at 09:31 am
When you get it working please post your final version as I might make one myself.

...R
23
Deutsch / Re: Tasterschaltung
Last post by combie - Today at 09:31 am
Ich habe hier auch noch eine Variante, allerdings mit 2 Problemen:
1. Es ist völlig ungetestet
2. Es wird die Verwirrung optimieren

Code: [Select]

#define ForEach(array,var) for(int var=0;var<(sizeof(array)/sizeof(array[0]));var++)

const byte sonderfunktion = 5; // 6te Taste im Block

byte RadioTastenBlock[] = {14,15,16,17,18,19};
byte RadioLedBlock[]    = {13,12,11,10,9,8};
byte ManTastenBlock[]   = {4,5};
byte ManLedBlock[]      = {7,6};

byte Tastenspeicher;

void initRadio()
{
  ForEach(RadioTastenBlock,i)
  {
    pinMode(RadioTastenBlock[i],INPUT); 
    pinMode(RadioLedBlock[i],OUTPUT); 
  }
  ForEach(ManTastenBlock,i)
  {
    pinMode(ManTastenBlock[i],INPUT); 
    pinMode(ManLedBlock[i],OUTPUT); 
  }
  setRadioTaste(0); // default setzen, erste Taste ist gedrückt
}

void setRadioTaste(byte taste)
{
  Tastenspeicher = taste; 
  ForEach(RadioLedBlock,i) digitalWrite(RadioLedBlock[i],i==taste); 
}


void tastenauswertung()
{
  ForEach(RadioTastenBlock,i)
    if(digitalRead(RadioTastenBlock[i]))
    {
       setRadioTaste(i);
       exit;
    };
   
  int count = 0;
  ForEach(ManLedBlock,i)
  {
    count += digitalRead(ManTastenBlock[i])?1:0;
    digitalWrite(ManLedBlock[i],(1 == count)&&(sonderfunktion == Tastenspeicher)); 
  }
}

void setup()
{
  initRadio();
}

void loop()
{
  tastenauswertung();
}





24
The j's above should be i's and i should be global.
I don't like using  i or j for loop variables because they can be difficult to read in amongst all the []. n, m, b. a etc are much easier to read IMHO.

...R
26

Threads merged.

27
Bar Sport / Re: [OT ITA] Lo spamm bar
Last post by Madwriter - Today at 09:28 am
arrichire dai il piu caro della cooler master costa 50€
però e da dire che comunque il mio notebook ha tutte le fessure sotto con i vari componenti quasi scoperti quindi chissà magari funziona
28
Sorry, but I am honest, maybe it is better I find other development board because of restrictions and missing functions in Arduino ????
I suspect you will find the exact same frustrations whatever board you choose.

From what I can see the problem is that you do not have a clear concept in your own mind - or at least that you have not managed to explain your concept to us.

Lots of people here have taken time to try to help you but (as far as I can see) you have either not tried to apply those comments to your problem or you have not used those comments as a basis for clarifying what you are trying to do in terms that others can understand.

I'm sure that 75% or more of creating a successful computer program is defining the requirement - and that requires absolutely ZERO knowledge of Arduino or C/C++ functions or any programming code.

If you can explain what you want to do there will be no difficulty getting help with the code.

...R
29
Project Guidance / Re: interrupt pins
Last post by raschemmel - Today at 09:23 am
If I am not mistaken, an xy stage comes with the END-LIMIT switches ehich as you pointed out are fail-safe DISABLE switches and are never intended to trigger except in a fault scenario but the user must provide and install opto interrupters and flags. If they were not present when purchasdd ig does nog mean they are unnecessary or that tgey shouldn't be added.
30
Is it splitting your ints up into bytes thats the issue?

Code: [Select]

int send_int = 398;
 
byte data[2] = { 0, 0 };
data[0] = ((byte*)(&send_int))[0];
data[1] = ((byte*)(&send_int))[1];
 
int recieve_int = *((int*)&data[0]);


Also if you have an array of ints, you can just straight cast them to byte* on each side.
[Transmitter Code]
     int send_int = Serial.read();
     byte data[2] = { 0, 0 };
     data[0] = ((byte*)(&send_int))[0];
     data[1] = ((byte*)(&send_int))[1];
     Mirf.send((byte *) &data);     
     //control codes are ..
     Serial.print(send_int); //for control
     Serial.print(":");
     Serial.print(*data);
     Serial.println("");

[control codes are writing: -1:255]


[Receiver Code]
     Mirf.getData((byte*) data);
     int recieve_int = *((int*)&data[0]);
     Serial.print(*((int*)&data[0]));
     Serial.print(":");
     Serial.print(*((int*)&data[1]));
     Serial.println("");

[i see that: -1:1023]
Pages: 1 2 [3] 4 5 ... 10