Loading...
Pages: 1 2 [3] 4 5 ... 10
 21 
 on: Today at 04:53:12 am 
Started by grantitoi77 - Last post by nid69ita
Devi racchiudere il codice con gli appositi tag. Altrimenti, 1 l'admin ti cazzia, 2 come vedi le parentesi quadre spariscono e vengono interpretate come corsivo (da un punto del codice in poi).
Modifica il post e metti il codice racchiuso tra questi due tag:    [ code]   e [ /code]     senza spazio (io l'ho messo per poterlo scrivere)
Oppure usi il pulsante con il simbolo #


Ma se carichi lo sketch su Arduino e vai nel "Monitor Seriale" dell'IDE, quali scritte appaiono?
Tutti quei Serial.println  servono per stampare sul monitor seriale dei messaggi.

 22 
 on: Today at 04:52:39 am 
Started by dkoc - Last post by PaulS
Why don't you take the next step and learn about functions?

Create a function that takes two pin numbers - one for the switch pin and one for the LED pin. In that function, read the switch state and set the LED state.

Code:
void readSwitchAndSetState(byte swiPin, byte ledPin)
{
   byte state = digitalRead(swiPin);
   digitalWrite(ledPin, state);
}

Then, call that function 4 times:

Code:
void loop()
{
   readSwitchAndSetState(2, 6);
   readSwitchAndSetState(3, 7);
   readSwitchAndSetState(4, 8);
   readSwitchAndSetState(5, 9);
}

The stuff you are doing for one set of pins in loop() now is exactly the same. Move that to a function, as shown here, to reduce the amount of code you have to write/modify/maintain/understand.

If you find that there is a problem with one set of input and output pins, it is likely that the problem affects the other three sets, too. Then, you have to fix the code 4 times. I only need to fix it once.

If you find that the wrong LED lights up when you press a given switch, then it is easy to see that it is the call to the function that is wrong, so it's much easier to see what needs to be fixed.

Oh, and when you get around to discovering that you want to press the switch once to turn the LED on and once to turn it off, fixing one set of code is going to be much easier.

Similarly, when you need to debounce the switches, doing it once is easier than doing it 4 times.

 23 
 on: Today at 04:50:19 am 
Started by AWOL - Last post by AWOL
This topic has been moved to Arduino Due.

http://forum.arduino.cc/index.php?topic=173054.0

 24 
 on: Today at 04:49:46 am 
Started by grantitoi77 - Last post by grantitoi77
Salve che mi puo aiutare a far accendere un led con un sms ,ho da poco acquistato arduino ma non conosco bene le istruzioni. smiley-cry
Spero che qualcuno mi rispondi perche ho guardato sul forum e non ci ho capito molto.

il modulo che ho è questo   http://www.ebay.it/itm/230911052682?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

Questo e il codice che ho scaricato da internet


Code:
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "inetGSM.h"
#include "sms.h"
#include "call.h"

InetGSM inet;
CallGSM call;
SMSGSM sms;

char msg[50];
int numdata;
char inSerial[50];
int i=0;
boolean started=false;

void setup()
{
  //Serial connection.
  Serial.begin(9600);
  Serial.println("GSM Shield testing.");
  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(2400)){
    Serial.println("\nStato=Prnoto");
    started=true; 
  }
  else Serial.println("\nstatus=IDLE");
  delay(5000);
  Serial.println("Qualita del segnale");
  gsm.SimpleWriteln("AT+CSQ");
};

void loop()
{
  //Read for new byte on serial hardware,
  //and write them on NewSoftSerial.
  serialhwread();
  //Read for new byte on NewSoftSerial.
  serialswread();
};

void serialhwread(){
  i=0;
  if (Serial.available() > 0){           
    while (Serial.available() > 0) {
      inSerial[i]=(Serial.read());
      delay(10);
      i++;     
    }
   
    inSerial[i]='\0';
    if(!strcmp(inSerial,"/END")){
      Serial.println("_");
      inSerial[0]=0x1a;
      inSerial[1]='\0';
      gsm.SimpleWriteln(inSerial);
    }
    //Test del segnale modem.
    if(!strcmp(inSerial,"TEST")){
      //sms.SendSMS("3460426430", "Arduino SMS");
      Serial.println("Qualita del segnale");
      gsm.SimpleWriteln("AT+CSQ");
     }
      //Leggi tuttu gli sms.
    if(!strcmp(inSerial,"SMS TUTTI")){
      Serial.println("Leggo tutti gli SMS");
      //gsm.SimpleWriteln("AT+CMGR=1");
      gsm.SimpleWriteln("AT+CMGL=\"ALL\"");
     }
    //Leggo il credito residuo.
    if(!strcmp(inSerial,"CREDITO")){
      Serial.println("Il credito residuo e =");
      call.Call("+39404");
     }
    //Read last message saved.
    if(!strcmp(inSerial,"MSG")){
      Serial.println(msg);
    }
    else{
      Serial.println(inSerial);
      gsm.SimpleWriteln(inSerial);
    }   
    inSerial[0]='\0';
  }
}

void serialswread(){
  gsm.SimpleRead();
}

 25 
 on: Today at 04:49:44 am 
Started by InYourMind - Last post by InYourMind
Bene, ci provero'.

 26 
 on: Today at 04:49:13 am 
Started by infobarquee - Last post by skizoh
Je ne suis pas du tout la pour t'aider !!  ]smiley

Mais sympa comme projet smiley

Skizo !

 27 
 on: Today at 04:47:57 am 
Started by laemmen - Last post by laemmen
Moin,

ich nutze ArduinoISP um Tinys direkt über das Arudino zu programmieren. Nun möchte ich gerne einen Tiny84 mit einem externen 8MHz Quarz betreiben, finde aber nur einen Core in denen dieser auf 16MHz gestellt werden kann. Jetzt dachte ich mir, dass man doch einfach die boards.txt anpassen kann, in der schließlich alle Einstellungen definiert sind. Hier mal der Auszug für den 'ATtiny84 @ 16 MHz  (external crystal; 4.3 V BOD)'

Code:
attiny84at16.name=ATtiny84 @ 16 MHz  (external crystal; 4.3 V BOD)

# The following do NOT work...
# attiny84at16.upload.using=avrispv2
# attiny84at16.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
attiny84at16.upload.using=arduino:arduinoisp
# attiny84at16.upload.protocol=avrispv2
# attiny84at16.upload.using=pololu

attiny84at16.upload.maximum_size=8192

# Frequency 8.0- MHz; Start-up time PWRDWN/RESET: 16K CK/14 CK + 65 ms; [CKSEL=1111 SUT=11]
# Brown-out detection level at VCC=4.3 V; [BODLEVEL=100]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]
# Serial program downloading (SPI) enabled; [SPIEN=0]

attiny84at16.bootloader.low_fuses=0xFF
attiny84at16.bootloader.high_fuses=0xD4
attiny84at16.bootloader.extended_fuses=0xFF
attiny84at16.bootloader.path=empty
attiny84at16.bootloader.file=empty84at16.hex

attiny84at16.build.mcu=attiny84
attiny84at16.build.f_cpu=16000000L
attiny84at16.build.core=tiny

Hat da jemand Ahnung von oder hat soetwas schon mal gemacht? Ich habe hier einen Fuse-Calculator gefunden, habe aber keine Ahnung was genau ich da auswählen muss...

Viele Grüße
Dennis

 28 
 on: Today at 04:47:51 am 
Started by InYourMind - Last post by PaoloP
Aggiungi dei serial print un po' qui e un po' lì, fai del buon debug aiutandoti con il monitor seriale.
Così è più o meno impossibile capire se il programma gira correttamente.

Questo
Code:
count2>>=1;
cos'è?  smiley-roll-sweat

 29 
 on: Today at 04:47:06 am 
Started by Korman - Last post by eintsius
Hi,

Tnx Timcki! Got it running. The library, when taken from downloaded unpacked folder was copied to inside multiple same-named folders. I removed the intermittent useless folders and now it compiles nicley!

 smiley


 30 
 on: Today at 04:46:55 am 
Started by Islandboy85 - Last post by fungus
I'm an aircraft mechanic by trade

So you should know what an "hourly rate" is...

(and that 10 boards for $15 is a bargain).

Pages: 1 2 [3] 4 5 ... 10