Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2011
    Location
    127.0.0.1
    Posts
    62
    Thanks
    18
    Thanked 0 Times in 0 Posts

    How to explode integer?

    Hello. I'm programming Arduino in C and I want to know how to explode integer.... In PHP I just need to write:
    PHP Code:
    $substring explode($string""); 
    please help me.

    I tried to use:
    Code:
    charAt();
    Code:
    void setup() {
      Serial.begin(9600);
    }
    
    void loop() {
      int sensorValue = analogRead(A1);
      analogWrite(A0, sensorValue);
      int a = analogRead(A1);
      String aa=(String)a;
      int a1 = aa.charAt(1);
      int a2 = aa.charAt(2);
      int a3 = aa.charAt(3);
      int a4 = aa.charAt(4);
      Serial.println("char at 1:" + a1);
      Serial.println("char at 2:" + a2);
      Serial.println("char at 3:" + a3);
      Serial.println("char at 4:" + a4);
      Serial.println("");
      Serial.println("sensor:" + sensorValue);
      Serial.println("");
      delay(1000);
    }
    but there was an error...it displays some crazy thigs in serial monitor

    Code:
    ş˝†:lŚ–}ľo/uk/gľpa/ď–^fž’ő){ńđC‡˝Ś˙.
    b/s.ň	mn\ŚŤđ]5�ăo
    đD/k}Ł—ťžŢt˙ĺăśďqňmź\ułdĚwĎ7Őkţ>ɦUdŽľěV_Ć˝˙ďţĺr]ű}^Fw˘]oŁOő]źa=]Zňű8[ć\*lľ9Z$ń˙ťşřčńzű˙lŽL-űŹĘăH•qż‡ż&i—˛~0ť˝qżţ?>űu{ţ3ăźfsż~{‘ˇŹ�ĂŻQŐă*1ĺňďŁ~inŰżţ‡~o(gm^.:˝Ş7NłŮ}l›ć/űkź–tőcDͷvň NŞą”NkmW`˙_ŚwEĽĄĆs{eűŠĽűőěăľ6Ůę]2ŹőĚŐňXz[=ăŽň�Š.�U˙6FţĘC֮?N…ł*gMj9wm�f‰lăyK›VS/ďŁţ{˙—	5Ż_�?n†cW…
    ő‡ľżc\oş˝?Ő*Ű`/~-Ď˙ęž/9}Dőm"KŰn|şGŻŇş—)ůůďociĄć}Űgg›Mk]ŽKŤgﯿEn߻n‡Ł›ş/›ćŻzűߵJń*B/t‚˙Ů7˙]~˙9n?›rĹžo~űłić3ůľkď[\}f`Ţ?‹˙˘Ě=>uĹůž5|Ă?uź~Ń|ŻzMs~u_ŽšnŤwŐŃ.?s›˘˙Ľ6sGľ;ŮGjGu&}Ok
    ű™3<PeŢŕӷEwűhwĹwŇz;ďoŐű˙•ŕi>?Ĺfeł9űŮ…ďĎ*tŽ?Xľvnő”>tk*…hęĎę/ňh“~ˇűoĚĎż…P6ůXmo^
    please is there any other way to explode integer?

    Thank you in advance.
    Last edited by sonic656; 01-14-2012 at 12:12 PM.

  • #2
    New Coder
    Join Date
    Sep 2011
    Location
    127.0.0.1
    Posts
    62
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Ohh. I found the bug, but it is not working It is displaying some crazy numbers:
    Code:
    char at 1:54
    char at 2:48
    char at 3:0
    char at 4:0
    
    sensor:659
    this is new code:
    Code:
    void setup() {
      Serial.begin(9600);
    }
    
    void loop() {
      int sensorValue = analogRead(A1);
      analogWrite(A0, sensorValue);
      int a = analogRead(A1);
      String aa=(String)a;
      int a1 = aa.charAt(1);
      int a2 = aa.charAt(2);
      int a3 = aa.charAt(3);
      int a4 = aa.charAt(4);
      Serial.print("char at 1:");  Serial.println(a1);
      Serial.print("char at 2:");  Serial.println(a2);
      Serial.print("char at 3:");  Serial.println(a3);
      Serial.print("char at 4:");  Serial.println(a4);
      Serial.println("");
      Serial.print("sensor:");  Serial.println(sensorValue);
      Serial.println("");
      delay(100);
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •