Fórum témák

» Több friss téma
Fórum » Arduino
A klónok CH340 Soros-USB illesztőjének drivere (Letöltés)
Lapozás: OK   206 / 847
(#) kapu48 válasza szikorapéter hozzászólására (») Márc 23, 2016 /
 
Akkor ki szeded a "TV out-ot" részt és szabadulfl memoria az LCD kezelésre!
(#) szikorapéter válasza kapu48 hozzászólására (») Márc 23, 2016 /
 
Már nem tudom mi a baj. Most vagy a gép,vagy a programozó,vagy pedig az emberi tényező (vagyis én. ) Megint hibaüzenet,egyet elhárítok ,jön a következő. Nekem az alap TinyBasic sem fut le a megán valamiért,ott állandóan az eeprom-ra hivatkozik. (most a TVout shield-et próbálom hogy hátha ezen jönne kép,de le se fut a program)

Mod:
Most ezt a hibaüzenetet hozza fel:
Arduino: 1.6.6 (Windows XP), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

avr-g++: error: missing filename after '-o'

exit status 1
Hiba a fordítás során.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
A hozzászólás módosítva: Márc 23, 2016
(#) kapu48 válasza szikorapéter hozzászólására (») Márc 23, 2016 /
 
Nállam enyi jött a monitoron:

HELLO
TinyBasic Plus v0.13

7439 bytes free.

4096 EEProm bytes total.

OK

>

Nem tudom, hogyan tovább?

Mit vár?
(#) szikorapéter válasza kapu48 hozzászólására (») Márc 23, 2016 /
 
Arduino 1.6.6-ot használok,a libaries file-ok a helyükön vannak,a program mégsem fordítódik le,írja a hibaüzenetet. (Klón mega 2560-at használok,viszont drivere fentvan,használtam már ezt a programozót internet shield-hez.
(#) kapu48 válasza szikorapéter hozzászólására (») Márc 23, 2016 /
 
Frissíts: Arduino 1.6.7-re
(#) Gabó válasza szikorapéter hozzászólására (») Márc 23, 2016 /
 
Próbáld meg régebbi verzióval. Pl az 1.5.5 azt hiszem. Ilyen fordítási hibák nálam is elő jöttek, és régebbi verzióba meg működött. Egy próbát megér.
(#) szikorapéter válasza kapu48 hozzászólására (») Márc 23, 2016 /
 
Az 1.6.8-at tudtam csak frissíteni,ez meg mindent törölt. Rakjam be a tvout libary-t,és próbáljam meg lefuttatni a sima TinyBasic-et?
(#) kapu48 válasza szikorapéter hozzászólására (») Márc 23, 2016 /
 
Az 1.6.7 már kipróbált verzió!
1.6.8-ast nem próbáltam még!

Miért nem próbáloda kezdésképen, az arduino Serial Monitorával?
(#) szikorapéter válasza kapu48 hozzászólására (») Márc 23, 2016 /
 
Rendben,akkor letöltöm az 1.6.7-et. Mivel nem fut le így a serial monitoron sem jön le semmi. Folyton csak a hibaüzeneteket kapom mindegyik programtól...
(#) szikorapéter válasza kapu48 hozzászólására (») Márc 23, 2016 /
 
Mára feladom a dolgot.... mostmár az 1.6.7 van fent most meg sok sok hibaüzenet jön elő:

Arduino: 1.6.7 (Windows XP), Alaplap:"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

In file included from C:\Documents and Settings\Ikaros\Local Settings\Application Data\Arduino15\packages\arduino\hardware\avr\1.6.10\cores\arduino/Arduino.h:28:0,

from sketch\TinyBasicPlus.ino.cpp:1:

TinyBasicPlus:347: error: variable 'keywords' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

static unsigned char keywords[] PROGMEM = {

^

TinyBasicPlus:439: error: variable 'func_tab' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

static unsigned char func_tab[] PROGMEM = {

^

TinyBasicPlus:454: error: variable 'to_tab' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

static unsigned char to_tab[] PROGMEM = {

^

TinyBasicPlus:459: error: variable 'step_tab' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

static unsigned char step_tab[] PROGMEM = {

^

TinyBasicPlus:464: error: variable 'relop_tab' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

static unsigned char relop_tab[] PROGMEM = {

^

TinyBasicPlus:484: error: variable 'highlow_tab' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

static unsigned char highlow_tab[] PROGMEM = {

^

exit status 1
variable 'keywords' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.


Az a TinyBasic amit küldtél átírható az én célomra?
(#) kapu48 válasza szikorapéter hozzászólására (») Márc 23, 2016 /
 
Alakul!

Javitsadki a const kulcs szó hiányzik pár helyröl:
static const unsigned char keywords[] PROGMEM = {
(#) szikorapéter válasza kapu48 hozzászólására (») Márc 23, 2016 /
 
Pótoltam a hiányzó helyekről. 2x annyi hibaüzenetet produkál most. Tuti én baltázok el valamit de nagyon,vagy csak ez a kínai panel ennyire hibás...
(#) kapu48 válasza szikorapéter hozzászólására (») Márc 23, 2016 /
 
Aludj rá 1-et!
(#) szikorapéter válasza kapu48 hozzászólására (») Márc 23, 2016 /
 
Holnap uj kör uj menet, Bár lehet az a TinyBasic amit próbálok lefuttatni nem megy,lehet letöltöm az "alapot" ,és csak hozzáadom a Tvout-ot.
(#) mechanika hozzászólása Márc 25, 2016 /
 
Sziasztok!

328P-nek van valamilyen energiatakarékos üzemmódja, ami alacsony fogyasztás mellett kb.: heti egy alkalommal lefuttatna egy ciklust?
(#) GPeti1977 válasza mechanika hozzászólására (») Márc 25, 2016 /
 
Van az AVR-eknek 6 energiatakarékos módjuk
"Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby, and Extended Standby"
olvasgasd az adatlapot.
Bár ahogy számolom heti egy alkalom felébresztést nem tudom hogy lehetne megoldani.
(#) mechanika hozzászólása Márc 25, 2016 /
 
Sziasztok!

DS1337-hez (rtc) kerestem alarm példát, de nem fordul le.
Csatolom a képét.
Valaki tudna segíteni, hogy mi lehet a hiba?!

Köszönöm!

hiba.PNG
    
(#) Kera_Will válasza mechanika hozzászólására (») Márc 25, 2016 / 1
 
Nem találja a hozzá tartozó #include <valami.h> sorban lévő függvényt/változót/hivatkozást a példaprogram forrássánál nézzél szét hátha emlegetnek valami *.h vagy hasonló fájlokat. Azokat is le kell tölteni és az arduino IDE által importálni mint library-kat (könyvtárakat).
A hozzászólás módosítva: Márc 25, 2016
(#) szikorapéter válasza szikorapéter hozzászólására (») Márc 25, 2016 /
 
Szép estét. Ujra elkeztem hát rémkedni az arduino-val. Töröltem a régi file-okat,és leszedtem egy sima alap TinyBasic-et. Ezzel semmi gond nem volt rögtön lefutott,serial monitoron keresztül (arduino uno-nál) 308byte szabad területet írt (az nagyon kevés szerintem....). Már csak a TVout-ot kell valahogy beleilleszteni,na meg a PS/2-es billentyűzetet. Persze ez mind vagy a megára megy fel,vagy pedig a due-ra (ha nem kell hozzá belenyulni +ban a programban,akkor due-ra kerül át).

Jó hír végre hogy ez a kép fogadott (bár serial monitoron át):
TinyBasic in C V0.02.

308 bytes free.

OK

>

Itt a kód amit használtam:
  1. // TinyBASIC.cpp : Defines the entry point for the console application.
  2. // Author: Mike Field <hamster@snap.net.nz>
  3. //
  4. // IF testing with Visual C
  5. //#include "stdafx.h"
  6. #define ARDUINO 1
  7.  
  8. // ASCII Characters
  9. #define CR              '\r'
  10. #define NL              '\n'
  11. #define TAB             '\t'
  12. #define BELL    '\b'
  13. #define SPACE   ' '
  14. #define CTRLC   0x03
  15. #define CTRLH   0x08
  16. #define CTRLS   0x13
  17. #define CTRLX   0x18
  18.  
  19. typedef short unsigned LINENUM;
  20. #if ARDUINO
  21.   #define ECHO_CHARS 1
  22. #else
  23.   #define ECHO_CHARS 0
  24. #endif
  25.  
  26. static unsigned char program[412];
  27. static unsigned char *txtpos,*list_line;
  28. static unsigned char expression_error;
  29. static unsigned char *tempsp;
  30.  
  31. /***********************************************************/
  32. // Keyword table and constants - the last character has 0x80 added to it
  33. static unsigned char keywords[] = {
  34.         'L','I','S','T'+0x80,
  35.         'L','O','A','D'+0x80,
  36.         'N','E','W'+0x80,
  37.         'R','U','N'+0x80,
  38.         'S','A','V','E'+0x80,
  39.         'N','E','X','T'+0x80,
  40.         'L','E','T'+0x80,
  41.         'I','F'+0x80,
  42.         'G','O','T','O'+0x80,
  43.         'G','O','S','U','B'+0x80,
  44.         'R','E','T','U','R','N'+0x80,
  45.         'R','E','M'+0x80,
  46.         'F','O','R'+0x80,
  47.         'I','N','P','U','T'+0x80,
  48.         'P','R','I','N','T'+0x80,
  49.         'P','O','K','E'+0x80,
  50.         'S','T','O','P'+0x80,
  51.         'B','Y','E'+0x80,
  52.         0
  53. };
  54.  
  55. #define KW_LIST         0
  56. #define KW_LOAD         1
  57. #define KW_NEW          2
  58. #define KW_RUN          3
  59. #define KW_SAVE         4
  60. #define KW_NEXT         5
  61. #define KW_LET          6
  62. #define KW_IF           7
  63. #define KW_GOTO         8
  64. #define KW_GOSUB        9
  65. #define KW_RETURN       10
  66. #define KW_REM          11
  67. #define KW_FOR          12
  68. #define KW_INPUT        13
  69. #define KW_PRINT        14
  70. #define KW_POKE         15
  71. #define KW_STOP         16
  72. #define KW_BYE          17
  73. #define KW_DEFAULT      18
  74.  
  75. struct stack_for_frame {
  76.         char frame_type;
  77.         char for_var;
  78.         short int terminal;
  79.         short int step;
  80.         unsigned char *current_line;
  81.         unsigned char *txtpos;
  82. };
  83.  
  84. struct stack_gosub_frame {
  85.         char frame_type;
  86.         unsigned char *current_line;
  87.         unsigned char *txtpos;
  88. };
  89.  
  90. static unsigned char func_tab[] = {
  91.         'P','E','E','K'+0x80,
  92.         'A','B','S'+0x80,
  93.         0
  94. };
  95. #define FUNC_PEEK    0
  96. #define FUNC_ABS         1
  97. #define FUNC_UNKNOWN 2
  98.  
  99. static unsigned char to_tab[] = {
  100.         'T','O'+0x80,
  101.         0
  102. };
  103.  
  104. static unsigned char step_tab[] = {
  105.         'S','T','E','P'+0x80,
  106.         0
  107. };
  108.  
  109. static unsigned char relop_tab[] = {
  110.         '>','='+0x80,
  111.         '<','>'+0x80,
  112.         '>'+0x80,
  113.         '='+0x80,
  114.         '<','='+0x80,
  115.         '<'+0x80,
  116.         0
  117. };
  118.  
  119. #define RELOP_GE                0
  120. #define RELOP_NE                1
  121. #define RELOP_GT                2
  122. #define RELOP_EQ                3
  123. #define RELOP_LE                4
  124. #define RELOP_LT                5
  125. #define RELOP_UNKNOWN   6
  126.  
  127. #define STACK_SIZE (sizeof(struct stack_for_frame)*5)
  128. #define VAR_SIZE sizeof(short int) // Size of variables in bytes
  129.  
  130. static unsigned char *stack_limit;
  131. static unsigned char *program_start;
  132. static unsigned char *program_end;
  133. static unsigned char *stack; // Software stack for things that should go on the CPU stack
  134. static unsigned char *variables_begin;
  135. static unsigned char *current_line;
  136. static unsigned char *sp;
  137. #define STACK_GOSUB_FLAG 'G'
  138. #define STACK_FOR_FLAG 'F'
  139. static unsigned char table_index;
  140. static LINENUM linenum;
  141.  
  142. static const unsigned char okmsg[]              = "OK";
  143. static const unsigned char whatmsg[]    = "What? ";
  144. static const unsigned char howmsg[]             =       "How?";
  145. static const unsigned char sorrymsg[]   = "Sorry!";
  146. static const unsigned char initmsg[]    = "TinyBasic in C V0.02.";
  147. static const unsigned char memorymsg[]  = " bytes free.";
  148. static const unsigned char breakmsg[]   = "break!";
  149. static const unsigned char unimplimentedmsg[]   = "Unimplemented";
  150. static const unsigned char backspacemsg[]               = "\b \b";
  151.  
  152. static int inchar(void);
  153. static void outchar(unsigned char c);
  154. static void line_terminator(void);
  155. static short int expression(void);
  156. static unsigned char breakcheck(void);
  157. /***************************************************************************/
  158. static void ignore_blanks(void)
  159. {
  160.         while(*txtpos == SPACE || *txtpos == TAB)
  161.                 txtpos++;
  162. }
  163.  
  164. /***************************************************************************/
  165. static void scantable(unsigned char *table)
  166. {
  167.         int i = 0;
  168.         table_index = 0;
  169.         while(1)
  170.         {
  171.                 // Run out of table entries?
  172.                 if(table[0] == 0)
  173.             return;
  174.  
  175.                 // Do we match this character?
  176.                 if(txtpos[i] == table[0])
  177.                 {
  178.                         i++;
  179.                         table++;
  180.                 }
  181.                 else
  182.                 {
  183.                         // do we match the last character of keywork (with 0x80 added)? If so, return
  184.                         if(txtpos[i]+0x80 == table[0])
  185.                         {
  186.                                 txtpos += i+1;  // Advance the pointer to following the keyword
  187.                                 ignore_blanks();
  188.                                 return;
  189.                         }
  190.  
  191.                         // Forward to the end of this keyword
  192.                         while((table[0] & 0x80) == 0)
  193.                                 table++;
  194.  
  195.                         // Now move on to the first character of the next word, and reset the position index
  196.                         table++;
  197.                         table_index++;
  198.                         ignore_blanks();
  199.                         i = 0;
  200.                 }
  201.         }
  202. }
  203.  
  204. /***************************************************************************/
  205. static void pushb(unsigned char b)
  206. {
  207.         sp--;
  208.         *sp = b;
  209. }
  210.  
  211. /***************************************************************************/
  212. static unsigned char popb()
  213. {
  214.         unsigned char b;
  215.         b = *sp;
  216.         sp++;
  217.         return b;
  218. }
  219.  
  220. /***************************************************************************/
  221. static void printnum(int num)
  222. {
  223.         int digits = 0;
  224.  
  225.         if(num < 0)
  226.         {
  227.                 num = -num;
  228.                 outchar('-');
  229.         }
  230.  
  231.         do {
  232.                 pushb(num%10+'0');
  233.                 num = num/10;
  234.                 digits++;
  235.         }
  236.         while (num > 0);
  237.  
  238.         while(digits > 0)
  239.         {
  240.                 outchar(popb());
  241.                 digits--;
  242.         }
  243. }
  244. /***************************************************************************/
  245. static unsigned short testnum(void)
  246. {
  247.         unsigned short num = 0;
  248.         ignore_blanks();
  249.        
  250.         while(*txtpos>= '0' && *txtpos <= '9' )
  251.         {
  252.                 // Trap overflows
  253.                 if(num >= 0xFFFF/10)
  254.                 {
  255.                         num = 0xFFFF;
  256.                         break;
  257.                 }
  258.  
  259.                 num = num *10 + *txtpos - '0';
  260.                 txtpos++;
  261.         }
  262.         return  num;
  263. }
  264.  
  265. /***************************************************************************/
  266. static void printmsgNoNL(const unsigned char *msg)
  267. {
  268.         while(*msg)
  269.         {
  270.                 outchar(*msg);
  271.                 msg++;
  272.         }
  273. }
  274.  
  275. /***************************************************************************/
  276. static unsigned char print_quoted_string(void)
  277. {
  278.         int i=0;
  279.         unsigned char delim = *txtpos;
  280.         if(delim != '"' && delim != '\'')
  281.                 return 0;
  282.         txtpos++;
  283.  
  284.         // Check we have a closing delimiter
  285.         while(txtpos[i] != delim)
  286.         {
  287.                 if(txtpos[i] == NL)
  288.                         return 0;
  289.                 i++;
  290.         }
  291.  
  292.         // Print the characters
  293.         while(*txtpos != delim)
  294.         {
  295.                 outchar(*txtpos);
  296.                 txtpos++;
  297.         }
  298.         txtpos++; // Skip over the last delimiter
  299.  
  300.         return 1;
  301. }
  302.  
  303. /***************************************************************************/
  304. static void printmsg(const unsigned char *msg)
  305. {
  306.         printmsgNoNL(msg);
  307.     line_terminator();
  308. }
  309.  
  310. /***************************************************************************/
  311. static void getln(char prompt)
  312. {
  313.         outchar(prompt);
  314.         txtpos = program_end+sizeof(LINENUM);
  315.  
  316.         while(1)
  317.         {
  318.                 char c = inchar();
  319.                 switch(c)
  320.                 {
  321.                         case NL:
  322.                                 break;
  323.                         case CR:
  324.                                 line_terminator();
  325.                                 // Terminate all strings with a NL
  326.                                 txtpos[0] = NL;
  327.                                 return;
  328.                         case CTRLH:
  329.                                 if(txtpos == program_end)
  330.                                         break;
  331.                                 txtpos--;
  332.                                 printmsg(backspacemsg);
  333.                                 break;
  334.                         default:
  335.                                 // We need to leave at least one space to allow us to shuffle the line into order
  336.                                 if(txtpos == variables_begin-2)
  337.                                         outchar(BELL);
  338.                                 else
  339.                                 {
  340.                                         txtpos[0] = c;
  341.                                         txtpos++;
  342. #if ECHO_CHARS
  343.                                         outchar(c);
  344. #endif
  345.                                 }
  346.                 }
  347.         }
  348. }
  349.  
  350. /***************************************************************************/
  351. static unsigned char *findline(void)
  352. {
  353.         unsigned char *line = program_start;
  354.         while(1)
  355.         {
  356.                 if(line == program_end)
  357.                         return line;
  358.  
  359.                 if(((LINENUM *)line)[0] >= linenum)
  360.                         return line;
  361.  
  362.                 // Add the line length onto the current address, to get to the next line;
  363.                 line += line[sizeof(LINENUM)];
  364.         }
  365. }
  366.  
  367. /***************************************************************************/
  368. static void toUppercaseBuffer(void)
  369. {
  370.         unsigned char *c = program_end+sizeof(LINENUM);
  371.         unsigned char quote = 0;
  372.  
  373.         while(*c != NL)
  374.         {
  375.                 // Are we in a quoted string?
  376.                 if(*c == quote)
  377.                         quote = 0;
  378.                 else if(*c == '"' || *c == '\'')
  379.                         quote = *c;
  380.                 else if(quote == 0 && *c >= 'a' && *c <= 'z')
  381.                         *c = *c + 'A' - 'a';
  382.                 c++;
  383.         }
  384. }
  385.  
  386. /***************************************************************************/
  387. void printline()
  388. {
  389.         LINENUM line_num;
  390.        
  391.         line_num = *((LINENUM *)(list_line));
  392.     list_line += sizeof(LINENUM) + sizeof(char);
  393.  
  394.         // Output the line */
  395.         printnum(line_num);
  396.         outchar(' ');
  397.         while(*list_line != NL)
  398.     {
  399.                 outchar(*list_line);
  400.                 list_line++;
  401.         }
  402.         list_line++;
  403.         line_terminator();
  404. }
  405.  
  406. /***************************************************************************/
  407. static short int expr4(void)
  408. {
  409.  
  410.         if(*txtpos == '0')
  411.         {
  412.                 txtpos++;
  413.                 return 0;
  414.         }
  415.  
  416.         if(*txtpos >= '1' && *txtpos <= '9')
  417.         {
  418.                 short int a = 0;
  419.                 do      {
  420.                         a = a*10 + *txtpos - '0';
  421.                         txtpos++;
  422.                 } while(*txtpos >= '0' && *txtpos <= '9');
  423.                 return a;
  424.         }
  425.  
  426.         // Is it a function or variable reference?
  427.         if(txtpos[0] >= 'A' && txtpos[0] <= 'Z')
  428.         {
  429.                 short int a;
  430.                 // Is it a variable reference (single alpha)
  431.                 if(txtpos[1] < 'A' || txtpos[1] > 'Z')
  432.                 {
  433.                         a = ((short int *)variables_begin)[*txtpos - 'A'];
  434.                         txtpos++;
  435.                         return a;
  436.                 }
  437.  
  438.                 // Is it a function with a single parameter
  439.                 scantable(func_tab);
  440.                 if(table_index == FUNC_UNKNOWN)
  441.                         goto expr4_error;
  442.  
  443.                 unsigned char f = table_index;
  444.  
  445.                 if(*txtpos != '(')
  446.                         goto expr4_error;
  447.  
  448.                 txtpos++;
  449.                 a = expression();
  450.                 if(*txtpos != ')')
  451.                                 goto expr4_error;
  452.                 txtpos++;
  453.                 switch(f)
  454.                 {
  455.                         case FUNC_PEEK:
  456.                                 return program[a];
  457.                         case FUNC_ABS:
  458.                                 if(a < 0)
  459.                                         return -a;
  460.                                 return a;
  461.                 }
  462.         }
  463.  
  464.         if(*txtpos == '(')
  465.         {
  466.                 short int a;
  467.                 txtpos++;
  468.                 a = expression();
  469.                 if(*txtpos != ')')
  470.                         goto expr4_error;
  471.  
  472.                 txtpos++;
  473.                 return a;
  474.         }
  475.  
  476. expr4_error:
  477.         expression_error = 1;
  478.         return 0;
  479.  
  480. }
  481.  
  482. /***************************************************************************/
  483. static short int expr3(void)
  484. {
  485.         short int a,b;
  486.  
  487.         a = expr4();
  488.         while(1)
  489.         {
  490.                 if(*txtpos == '*')
  491.                 {
  492.                         txtpos++;
  493.                         b = expr4();
  494.                         a *= b;
  495.                 }
  496.                 else if(*txtpos == '/')
  497.                 {
  498.                         txtpos++;
  499.                         b = expr4();
  500.                         if(b != 0)
  501.                                 a /= b;
  502.                         else
  503.                                 expression_error = 1;
  504.                 }
  505.                 else
  506.                         return a;
  507.         }
  508. }
  509.  
  510. /***************************************************************************/
  511. static short int expr2(void)
  512. {
  513.         short int a,b;
  514.  
  515.         if(*txtpos == '-' || *txtpos == '+')
  516.                 a = 0;
  517.         else
  518.                 a = expr3();
  519.  
  520.         while(1)
  521.         {
  522.                 if(*txtpos == '-')
  523.                 {
  524.                         txtpos++;
  525.                         b = expr3();
  526.                         a -= b;
  527.                 }
  528.                 else if(*txtpos == '+')
  529.                 {
  530.                         txtpos++;
  531.                         b = expr3();
  532.                         a += b;
  533.                 }
  534.                 else
  535.                         return a;
  536.         }
  537. }
  538. /***************************************************************************/
  539. static short int expression(void)
  540. {
  541.         short int a,b;
  542.  
  543.         a = expr2();
  544.         // Check if we have an error
  545.         if(expression_error)    return a;
  546.  
  547.         scantable(relop_tab);
  548.         if(table_index == RELOP_UNKNOWN)
  549.                 return a;
  550.        
  551.         switch(table_index)
  552.         {
  553.         case RELOP_GE:
  554.                 b = expr2();
  555.                 if(a >= b) return 1;
  556.                 break;
  557.         case RELOP_NE:
  558.                 b = expr2();
  559.                 if(a != b) return 1;
  560.                 break;
  561.         case RELOP_GT:
  562.                 b = expr2();
  563.                 if(a > b) return 1;
  564.                 break;
  565.         case RELOP_EQ:
  566.                 b = expr2();
  567.                 if(a == b) return 1;
  568.                 break;
  569.         case RELOP_LE:
  570.                 b = expr2();
  571.                 if(a <= b) return 1;
  572.                 break;
  573.         case RELOP_LT:
  574.                 b = expr2();
  575.                 if(a < b) return 1;
  576.                 break;
  577.         }
  578.         return 0;
  579. }
  580.  
  581. /***************************************************************************/
  582. void loop()
  583. {
  584.         unsigned char *start;
  585.         unsigned char *newEnd;
  586.         unsigned char linelen;
  587.        
  588.         program_start = program;
  589.         program_end = program_start;
  590.         sp = program+sizeof(program);  // Needed for printnum
  591.         stack_limit = program+sizeof(program)-STACK_SIZE;
  592.         variables_begin = stack_limit - 27*VAR_SIZE;
  593.         printmsg(initmsg);
  594.         printnum(variables_begin-program_end);
  595.         printmsg(memorymsg);
  596.  
  597. warmstart:
  598.         // this signifies that it is running in 'direct' mode.
  599.         current_line = 0;
  600.         sp = program+sizeof(program);  
  601.         printmsg(okmsg);
  602.  
  603. prompt:
  604.         getln('>');
  605.         toUppercaseBuffer();
  606.  
  607.         txtpos = program_end+sizeof(unsigned short);
  608.  
  609.         // Find the end of the freshly entered line
  610.         while(*txtpos != NL)
  611.                 txtpos++;
  612.  
  613.         // Move it to the end of program_memory
  614.         {
  615.                 unsigned char *dest;
  616.                 dest = variables_begin-1;
  617.                 while(1)
  618.                 {
  619.                         *dest = *txtpos;
  620.                         if(txtpos == program_end+sizeof(unsigned short))
  621.                                 break;
  622.                         dest--;
  623.                         txtpos--;
  624.                 }
  625.                 txtpos = dest;
  626.         }
  627.  
  628.         // Now see if we have a line number
  629.         linenum = testnum();
  630.         ignore_blanks();
  631.         if(linenum == 0)
  632.                 goto direct;
  633.  
  634.         if(linenum == 0xFFFF)
  635.                 goto qhow;
  636.  
  637.         // Find the length of what is left, including the (yet-to-be-populated) line header
  638.         linelen = 0;
  639.         while(txtpos[linelen] != NL)
  640.                 linelen++;
  641.         linelen++; // Include the NL in the line length
  642.         linelen += sizeof(unsigned short)+sizeof(char); // Add space for the line number and line length
  643.  
  644.         // Now we have the number, add the line header.
  645.         txtpos -= 3;
  646.         *((unsigned short *)txtpos) = linenum;
  647.         txtpos[sizeof(LINENUM)] = linelen;
  648.  
  649.  
  650.         // Merge it into the rest of the program
  651.         start = findline();
  652.  
  653.         // If a line with that number exists, then remove it
  654.         if(start != program_end && *((LINENUM *)start) == linenum)
  655.         {
  656.                 unsigned char *dest, *from;
  657.                 unsigned tomove;
  658.  
  659.                 from = start + start[sizeof(LINENUM)];
  660.                 dest = start;
  661.  
  662.                 tomove = program_end - from;
  663.                 while( tomove > 0)
  664.                 {
  665.                         *dest = *from;
  666.                         from++;
  667.                         dest++;
  668.                         tomove--;
  669.                 }      
  670.                 program_end = dest;
  671.         }
  672.  
  673.         if(txtpos[sizeof(LINENUM)+sizeof(char)] == NL) // If the line has no txt, it was just a delete
  674.                 goto prompt;
  675.  
  676.  
  677.  
  678.         // Make room for the new line, either all in one hit or lots of little shuffles
  679.         while(linelen > 0)
  680.         {      
  681.                 unsigned int tomove;
  682.                 unsigned char *from,*dest;
  683.                 unsigned int space_to_make;
  684.        
  685.                 space_to_make = txtpos - program_end;
  686.  
  687.                 if(space_to_make > linelen)
  688.                         space_to_make = linelen;
  689.                 newEnd = program_end+space_to_make;
  690.                 tomove = program_end - start;
  691.  
  692.  
  693.                 // Source and destination - as these areas may overlap we need to move bottom up
  694.                 from = program_end;
  695.                 dest = newEnd;
  696.                 while(tomove > 0)
  697.                 {
  698.                         from--;
  699.                         dest--;
  700.                         *dest = *from;
  701.                         tomove--;
  702.                 }
  703.  
  704.                 // Copy over the bytes into the new space
  705.                 for(tomove = 0; tomove < space_to_make; tomove++)
  706.                 {
  707.                         *start = *txtpos;
  708.                         txtpos++;
  709.                         start++;
  710.                         linelen--;
  711.                 }
  712.                 program_end = newEnd;
  713.         }
  714.         goto prompt;
  715.  
  716. unimplemented:
  717.         printmsg(unimplimentedmsg);
  718.         goto prompt;
  719.  
  720. qhow:  
  721.         printmsg(howmsg);
  722.         goto prompt;
  723.  
  724. qwhat: 
  725.         printmsgNoNL(whatmsg);
  726.         if(current_line != NULL)
  727.         {
  728.            unsigned char tmp = *txtpos;
  729.                    if(*txtpos != NL)
  730.                                 *txtpos = '^';
  731.            list_line = current_line;
  732.            printline();
  733.            *txtpos = tmp;
  734.         }
  735.     line_terminator();
  736.         goto prompt;
  737.  
  738. qsorry:
  739.         printmsg(sorrymsg);
  740.         goto warmstart;
  741.  
  742. run_next_statement:
  743.         while(*txtpos == ':')
  744.                 txtpos++;
  745.         ignore_blanks();
  746.         if(*txtpos == NL)
  747.                 goto execnextline;
  748.         goto interperateAtTxtpos;
  749.  
  750. direct:
  751.         txtpos = program_end+sizeof(LINENUM);
  752.         if(*txtpos == NL)
  753.                 goto prompt;
  754.  
  755. interperateAtTxtpos:
  756.         if(breakcheck())
  757.         {
  758.           printmsg(breakmsg);
  759.           goto warmstart;
  760.         }
  761.  
  762.         scantable(keywords);
  763.  
  764.         switch(table_index)
  765.         {
  766.                 case KW_LIST:
  767.                         goto list;
  768.                 case KW_LOAD:
  769.                         goto unimplemented; /////////////////
  770.                 case KW_NEW:
  771.                         if(txtpos[0] != NL)
  772.                                 goto qwhat;
  773.                         program_end = program_start;
  774.                         goto prompt;
  775.                 case KW_RUN:
  776.                         current_line = program_start;
  777.                         goto execline;
  778.                 case KW_SAVE:
  779.                         goto unimplemented; //////////////////////
  780.                 case KW_NEXT:
  781.                         goto next;
  782.                 case KW_LET:
  783.                         goto assignment;
  784.                 case KW_IF:
  785.                         short int val;
  786.                         expression_error = 0;
  787.                         val = expression();
  788.                         if(expression_error || *txtpos == NL)
  789.                                 goto qhow;
  790.                         if(val != 0)
  791.                                 goto interperateAtTxtpos;
  792.                         goto execnextline;
  793.  
  794.                 case KW_GOTO:
  795.                         expression_error = 0;
  796.                         linenum = expression();
  797.                         if(expression_error || *txtpos != NL)
  798.                                 goto qhow;
  799.                         current_line = findline();
  800.                         goto execline;
  801.  
  802.                 case KW_GOSUB:
  803.                         goto gosub;
  804.                 case KW_RETURN:
  805.                         goto gosub_return;
  806.                 case KW_REM:   
  807.                         goto execnextline;      // Ignore line completely
  808.                 case KW_FOR:
  809.                         goto forloop;
  810.                 case KW_INPUT:
  811.                         goto input;
  812.                 case KW_PRINT:
  813.                         goto print;
  814.                 case KW_POKE:
  815.                         goto poke;
  816.                 case KW_STOP:
  817.                         // This is the easy way to end - set the current line to the end of program attempt to run it
  818.                         if(txtpos[0] != NL)
  819.                                 goto qwhat;
  820.                         current_line = program_end;
  821.                         goto execline;
  822.                 case KW_BYE:
  823.                         // Leave the basic interperater
  824.                         return;
  825.                 case KW_DEFAULT:
  826.                         goto assignment;
  827.                 default:
  828.                         break;
  829.         }
  830.        
  831. execnextline:
  832.         if(current_line == NULL)                // Processing direct commands?
  833.                 goto prompt;
  834.         current_line +=  current_line[sizeof(LINENUM)];
  835.  
  836. execline:
  837.         if(current_line == program_end) // Out of lines to run
  838.                 goto warmstart;
  839.         txtpos = current_line+sizeof(LINENUM)+sizeof(char);
  840.         goto interperateAtTxtpos;
  841.  
  842. input:
  843.         {
  844.                 unsigned char var;
  845.                 ignore_blanks();
  846.                 if(*txtpos < 'A' || *txtpos > 'Z')
  847.                         goto qwhat;
  848.                 var = *txtpos;
  849.                 txtpos++;
  850.                 ignore_blanks();
  851.                 if(*txtpos != NL && *txtpos != ':')
  852.                         goto qwhat;
  853.                 ((short int *)variables_begin)[var-'A'] = 99;
  854.  
  855.                 goto run_next_statement;
  856.         }
  857. forloop:
  858.         {
  859.                 unsigned char var;
  860.                 short int initial, step, terminal;
  861.                 ignore_blanks();
  862.                 if(*txtpos < 'A' || *txtpos > 'Z')
  863.                         goto qwhat;
  864.                 var = *txtpos;
  865.                 txtpos++;
  866.                 ignore_blanks();
  867.                 if(*txtpos != '=')
  868.                         goto qwhat;
  869.                 txtpos++;
  870.                 ignore_blanks();
  871.  
  872.                 expression_error = 0;
  873.                 initial = expression();
  874.                 if(expression_error)
  875.                         goto qwhat;
  876.        
  877.                 scantable(to_tab);
  878.                 if(table_index != 0)
  879.                         goto qwhat;
  880.        
  881.                 terminal = expression();
  882.                 if(expression_error)
  883.                         goto qwhat;
  884.        
  885.                 scantable(step_tab);
  886.                 if(table_index == 0)
  887.                 {
  888.                         step = expression();
  889.                         if(expression_error)
  890.                                 goto qwhat;
  891.                 }
  892.                 else
  893.                         step = 1;
  894.                 ignore_blanks();
  895.                 if(*txtpos != NL && *txtpos != ':')
  896.                         goto qwhat;
  897.  
  898.  
  899.                 if(!expression_error && *txtpos == NL)
  900.                 {
  901.                         struct stack_for_frame *f;
  902.                         if(sp + sizeof(struct stack_for_frame) < stack_limit)
  903.                                 goto qsorry;
  904.  
  905.                         sp -= sizeof(struct stack_for_frame);
  906.                         f = (struct stack_for_frame *)sp;
  907.                         ((short int *)variables_begin)[var-'A'] = initial;
  908.                         f->frame_type = STACK_FOR_FLAG;
  909.                         f->for_var = var;
  910.                         f->terminal = terminal;
  911.                         f->step     = step;
  912.                         f->txtpos   = txtpos;
  913.                         f->current_line = current_line;
  914.                         goto run_next_statement;
  915.                 }
  916.         }
  917.         goto qhow;
  918.  
  919. gosub:
  920.         expression_error = 0;
  921.         linenum = expression();
  922.         if(!expression_error && *txtpos == NL)
  923.         {
  924.                 struct stack_gosub_frame *f;
  925.                 if(sp + sizeof(struct stack_gosub_frame) < stack_limit)
  926.                         goto qsorry;
  927.  
  928.                 sp -= sizeof(struct stack_gosub_frame);
  929.                 f = (struct stack_gosub_frame *)sp;
  930.                 f->frame_type = STACK_GOSUB_FLAG;
  931.                 f->txtpos = txtpos;
  932.                 f->current_line = current_line;
  933.                 current_line = findline();
  934.                 goto execline;
  935.         }
  936.         goto qhow;
  937.  
  938. next:
  939.         // Fnd the variable name
  940.         ignore_blanks();
  941.         if(*txtpos < 'A' || *txtpos > 'Z')
  942.                 goto qhow;
  943.         txtpos++;
  944.         ignore_blanks();
  945.         if(*txtpos != ':' && *txtpos != NL)
  946.                 goto qwhat;
  947.        
  948. gosub_return:
  949.         // Now walk up the stack frames and find the frame we want, if present
  950.         tempsp = sp;
  951.         while(tempsp < program+sizeof(program)-1)
  952.         {
  953.                 switch(tempsp[0])
  954.                 {
  955.                         case STACK_GOSUB_FLAG:
  956.                                 if(table_index == KW_RETURN)
  957.                                 {
  958.                                         struct stack_gosub_frame *f = (struct stack_gosub_frame *)tempsp;
  959.                                         current_line    = f->current_line;
  960.                                         txtpos                  = f->txtpos;
  961.                                         sp += sizeof(struct stack_gosub_frame);
  962.                                         goto run_next_statement;
  963.                                 }
  964.                                 // This is not the loop you are looking for... so Walk back up the stack
  965.                                 tempsp += sizeof(struct stack_gosub_frame);
  966.                                 break;
  967.                         case STACK_FOR_FLAG:
  968.                                 // Flag, Var, Final, Step
  969.                                 if(table_index == KW_NEXT)
  970.                                 {
  971.                                         struct stack_for_frame *f = (struct stack_for_frame *)tempsp;
  972.                                         // Is the the variable we are looking for?
  973.                                         if(txtpos[-1] == f->for_var)
  974.                                         {
  975.                                                 short int *varaddr = ((short int *)variables_begin) + txtpos[-1] - 'A';
  976.                                                 *varaddr = *varaddr + f->step;
  977.                                                 // Use a different test depending on the sign of the step increment
  978.                                                 if((f->step > 0 && *varaddr <= f->terminal) || (f->step < 0 && *varaddr >= f->terminal))
  979.                                                 {
  980.                                                         // We have to loop so don't pop the stack
  981.                                                         txtpos = f->txtpos;
  982.                                                         current_line = f->current_line;
  983.                                                         goto run_next_statement;
  984.                                                 }
  985.                                                 // We've run to the end of the loop. drop out of the loop, popping the stack
  986.                                                 sp = tempsp + sizeof(struct stack_for_frame);
  987.                                                 goto run_next_statement;
  988.                                         }
  989.                                 }
  990.                                 // This is not the loop you are looking for... so Walk back up the stack
  991.                                 tempsp += sizeof(struct stack_for_frame);
  992.                                 break;
  993.                         default:
  994.                                 printf("Stack is stuffed!\n");
  995.                                 goto warmstart;
  996.                 }
  997.         }
  998.         // Didn't find the variable we've been looking for
  999.         goto qhow;
  1000.  
  1001. assignment:
  1002.         {
  1003.                 short int value;
  1004.                 short int *var;
  1005.  
  1006.                 if(*txtpos < 'A' || *txtpos > 'Z')
  1007.                         goto qhow;
  1008.                 var = (short int *)variables_begin + *txtpos - 'A';
  1009.                 txtpos++;
  1010.  
  1011.                 ignore_blanks();
  1012.  
  1013.                 if (*txtpos != '=')
  1014.                         goto qwhat;
  1015.                 txtpos++;
  1016.                 ignore_blanks();
  1017.                 expression_error = 0;
  1018.                 value = expression();
  1019.                 if(expression_error)
  1020.                         goto qwhat;
  1021.                 // Check that we are at the end of the statement
  1022.                 if(*txtpos != NL && *txtpos != ':')
  1023.                         goto qwhat;
  1024.                 *var = value;
  1025.         }
  1026.         goto run_next_statement;
  1027. poke:
  1028.         {
  1029.                 short int value;
  1030.                 unsigned char *address;
  1031.  
  1032.                 // Work out where to put it
  1033.                 expression_error = 0;
  1034.                 value = expression();
  1035.                 if(expression_error)
  1036.                         goto qwhat;
  1037.                 address = (unsigned char *)value;
  1038.  
  1039.                 // check for a comma
  1040.                 ignore_blanks();
  1041.                 if (*txtpos != ',')
  1042.                         goto qwhat;
  1043.                 txtpos++;
  1044.                 ignore_blanks();
  1045.  
  1046.                 // Now get the value to assign
  1047.                 expression_error = 0;
  1048.                 value = expression();
  1049.                 if(expression_error)
  1050.                         goto qwhat;
  1051.                 printf("Poke %p value %i\n",address, (unsigned char)value);
  1052.                 // Check that we are at the end of the statement
  1053.                 if(*txtpos != NL && *txtpos != ':')
  1054.                         goto qwhat;
  1055.         }
  1056.         goto run_next_statement;
  1057.  
  1058. list:
  1059.         linenum = testnum(); // Retuns 0 if no line found.
  1060.  
  1061.         // Should be EOL
  1062.         if(txtpos[0] != NL)
  1063.                 goto qwhat;
  1064.  
  1065.         // Find the line
  1066.         list_line = findline();
  1067.         while(list_line != program_end)
  1068.           printline();
  1069.         goto warmstart;
  1070.  
  1071. print:
  1072.         // If we have an empty list then just put out a NL
  1073.         if(*txtpos == ':' )
  1074.         {
  1075.         line_terminator();
  1076.                 txtpos++;
  1077.                 goto run_next_statement;
  1078.         }
  1079.         if(*txtpos == NL)
  1080.         {
  1081.                 goto execnextline;
  1082.         }
  1083.  
  1084.         while(1)
  1085.         {
  1086.                 ignore_blanks();
  1087.                 if(print_quoted_string())
  1088.                 {
  1089.                         ;
  1090.                 }
  1091.                 else if(*txtpos == '"' || *txtpos == '\'')
  1092.                         goto qwhat;
  1093.                 else
  1094.                 {
  1095.                         short int e;
  1096.                         expression_error = 0;
  1097.                         e = expression();
  1098.                         if(expression_error)
  1099.                                 goto qwhat;
  1100.                         printnum(e);
  1101.                 }
  1102.  
  1103.                 // At this point we have three options, a comma or a new line
  1104.                 if(*txtpos == ',')
  1105.                         txtpos++;       // Skip the comma and move onto the next
  1106.                 else if(txtpos[0] == ';' && (txtpos[1] == NL || txtpos[1] == ':'))
  1107.                 {
  1108.                         txtpos++; // This has to be the end of the print - no newline
  1109.                         break;
  1110.                 }
  1111.                 else if(*txtpos == NL || *txtpos == ':')
  1112.                 {
  1113.                         line_terminator();      // The end of the print statement
  1114.                         break;
  1115.                 }
  1116.                 else
  1117.                         goto qwhat;    
  1118.         }
  1119.         goto run_next_statement;
  1120. }
  1121.  
  1122. /***************************************************************************/
  1123. static void line_terminator(void)
  1124. {
  1125.         outchar(NL);
  1126.         outchar(CR);
  1127. }
  1128.  
  1129. /***********************************************************/
  1130. void setup()
  1131. {
  1132. #if ARDUINO
  1133.         Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
  1134. #endif
  1135. }
  1136.  
  1137. /***********************************************************/
  1138. static unsigned char breakcheck(void)
  1139. {
  1140. #if ARDUINO
  1141.   if(Serial.available())
  1142.     return Serial.read() == CTRLC;
  1143.   return 0;
  1144. #else
  1145.   if(kbhit())
  1146.     return getch() == CTRLC;
  1147.    else
  1148.      return 0;
  1149. #endif
  1150. }
  1151. /***********************************************************/
  1152. static int inchar()
  1153. {
  1154. #if ARDUINO
  1155.   while(1)
  1156.   {
  1157.     if(Serial.available())
  1158.       return Serial.read();
  1159.   }
  1160. #else
  1161.         return getchar();
  1162. #endif
  1163. }
  1164.  
  1165. /***********************************************************/
  1166. static void outchar(unsigned char c)
  1167. {
  1168. #if ARDUINO
  1169.   Serial.write(c);
  1170. #else
  1171.         putchar(c);
  1172. #endif
  1173. }
(#) szikorapéter válasza szikorapéter hozzászólására (») Márc 26, 2016 /
 
Végül feltöltöttem az Arduino Due-ra is a Tiny Basic-et. Érdekes dolog jött elő serial monitoron:
˙˙TinyBasic in C V0.02.

278 bytes free.

OK

>
Miért van hogy kevesebbnek látja a memóriát egy jóval nagyobb processzor esetében?
(#) kapu48 válasza szikorapéter hozzászólására (») Márc 26, 2016 /
 
Gondolom, azért mert lefoglalja a memóriát a Basic programnak.

Ezt majd akkor veszed észre, ha az Unora feltölthetsz, mondjuk 100 sor Basic programot?
A Duera viszont 2000 soros program is felmegy!

Ehhez viszont már kellene SDram kezelés is, hogy el is tudjad menteni fájlba, utána betölteni ismét, a programodat.
Kinek van kedve 2000 sort töbször is begépelni?
(#) szikorapéter válasza kapu48 hozzászólására (») Márc 26, 2016 /
 
Este már lemaradt egy fontos dolog sajnos.
Időközben kiderült hogy az újonnan használt Tiny Basic kicsit hibás,így lecseréltem,a DUE-ra feltöltöttem,és kiderült hogy 2180 byte szabad hely még mindig van.
Már csak ehhez kéne az SD kártya kezelés, a PS/2-es billentyűzet,és egy TVout libary.
(#) mechanika válasza Kera_Will hozzászólására (») Márc 26, 2016 /
 
köszi
(#) david10 hozzászólása Márc 26, 2016 /
 
Sziasztok,
Építettem ATTiny85-el egy TV ki/be kapcsolot. (Az Arduinoval tudom programozni.)
Az interneten találtam egy forráskódot a NEC IR protokolhoz.
Minden müködik,de a program a PB1-es lábon küldi a jelet, és nekem a PB2-esen kellene küldje.
A hárdver része kész van pontosabban össze is van ragasztva.
Csatoltam az eredeti, PB1-es lábon küldő forráskódot: A valóságban nincsen benne ennyi üres sor, de csak igy sikerült feltölteni az forumra.
  1. namespace Codes
  2. {
  3. typedef uint32_t Code;
  4. namespace Power
  5.  {
  6. Code Toggle = 0x20DF10EF;
  7.  }
  8. }
  9. namespace IR
  10. {
  11. class Sender
  12. {
  13.   uint8_t pins;
  14. public:
  15.   Sender(uint8_t pins):
  16.     pins(pins)
  17.   {
  18.   }
  19.   void blink(unsigned long us)
  20.   {
  21.     for (size_t i = 0; i < (us / 26); i++)
  22.     {
  23.       PORTB |= pins;
  24.       delayMicroseconds(9);
  25.       PORTB &= ~pins;
  26.       delayMicroseconds(9);
  27.     }
  28.   }
  29.   void header()
  30.   {
  31.     blink(9000);
  32.     delayMicroseconds(4500);
  33.   }
  34.   void one()
  35.   {
  36.     blink(562);
  37.     delayMicroseconds(1686);
  38.   }
  39.   void zero()
  40.   {
  41.     blink(562);
  42.     delayMicroseconds(562);
  43.   }
  44.   void send(Codes::Code code, unsigned int times = 2)
  45.   {
  46.     for (unsigned int i = 0; i < times; ++i)
  47.     {
  48.       actuallySend(code);
  49.       delayMicroseconds(2250);
  50.     }
  51.   }
  52.   void actuallySend(Codes::Code code)
  53.   {
  54.     header();
  55.     for (unsigned int i = 0; i < 32; ++i, code <<= 1)
  56.     {
  57.       if (code & 0x80000000)
  58.       {
  59.         one();
  60.       }
  61.       else
  62.       {
  63.         zero();
  64.       }
  65.     }
  66.     blink(562);
  67.   }
  68. };
  69. }
  70. IR::Sender sender(2);
  71. void setup()
  72. {
  73.   PORTB = 0;
  74.   DDRB |= 2;
  75. }
  76.  
  77. void loop()
  78. {
  79.  sender.send(Codes::Power::Toggle);    
  80. }

Szerintetek mit kellene változtatni a forráskódban, hogy a PB2-es lábon küldje?
Aki tud segíteni a modosításban, annak a segítségét előre is köszönöm!

85ir.png
    
(#) Balázs válasza david10 hozzászólására (») Márc 26, 2016 /
 
A 70. és a 74. sorban lévő 2-eseket cseréld ki 4-esekre.
(#) david10 válasza Balázs hozzászólására (») Márc 26, 2016 /
 
Köszönöm a válaszod! Most a PB2-es lábon küldi és a TV-t ki és be kapcsolja.
Hogyha valaki megszeretné építeni, akkor írjon privátban és segítek neki
(#) jeges hozzászólása Márc 27, 2016 /
 
sziasztok!
Kérnék egy kis segitséget:
soft start efektusra van szükségem és müködik de csak felfutási álapotban az az 0....255 felfut és vége ez igy ok is ez kelene vissza felé 255..0 is de tulcsordul és ujra kezdi a müvelette nincs vége
!
felfutó kod
  1. int led = 9;           // the PWM pin the LED is attached to
  2.     int brightness = 0;    // how bright the LED is
  3.     int fadeAmount = 5;    // how many points to fade the LED by
  4.  
  5.  
  6.     void setup() {
  7.      
  8.       pinMode(led, OUTPUT);
  9.     }
  10.  
  11.  
  12.     void loop() {
  13.      
  14.       analogWrite(led, brightness);
  15.  
  16.      
  17.       brightness = brightness + fadeAmount;
  18.  
  19.      
  20.       if (brightness > 255)
  21.       {
  22.         brightness = 255;
  23.        
  24.       }
  25.      
  26.       delay(30);
  27.     }


lefutó kod ami tulcsordul:

  1. int led = 9;           // the PWM pin the LED is attached to
  2. int brightness = 0;    // how bright the LED is
  3. int fadeAmount = 5;    // how many points to fade the LED by
  4.  
  5.  
  6. void setup() {
  7.  
  8.   pinMode(led, OUTPUT);
  9. }
  10.  
  11.  
  12. void loop() {
  13.  
  14.   analogWrite(led, brightness);
  15.  
  16.  
  17.   brightness = brightness - fadeAmount;
  18.  
  19.  
  20.   if (brightness > 255)
  21.   {
  22.     brightness = 255;
  23.    
  24.   }
  25.  
  26.   delay(30);
  27. }
(#) Balázs válasza jeges hozzászólására (») Márc 27, 2016 /
 
Nulláról indítod, majd mindig kivonsz belőle 5-öt, és azt vizsgálod, hogy mikor lesz nagyobb 255-nél. Még jó, hogy így nem megy.
  1. int led = 9;           // the PWM pin the LED is attached to
  2.     int brightness = 255;    // how bright the LED is
  3.     int fadeAmount = 5;    // how many points to fade the LED by
  4.      
  5.      
  6.     void setup() {
  7.      
  8.       pinMode(led, OUTPUT);
  9.     }
  10.      
  11.      
  12.     void loop() {
  13.      
  14.       analogWrite(led, brightness);
  15.      
  16.      
  17.       brightness = brightness - fadeAmount;
  18.      
  19.      
  20.       if (brightness < 0)
  21.       {
  22.         brightness = 0;
  23.        
  24.       }
  25.      
  26.       delay(30);
  27.     }
(#) trickentrack hozzászólása Márc 27, 2016 /
 
Üdv!

Valami leírásban találkoztam ezzel az arduino uno nevű programozóval!
Rákerestem ebayen és rengeteg modult adott ki. Akkor ez az egész, hogy működik? Ha veszek egy ilyen arduino uno-t akkor ezt bele kell építenem az áramkörbe? Úgy értem, hogy minden projekthez kell egy ilyen arduino uno? Vagy valaki elmagyarázná, hogy hogy működik ez az egész?

Előre is köszönöm!

Szép estét!
Következő: »»   206 / 847
Bejelentkezés

Belépés

Hirdetés
XDT.hu
Az oldalon sütiket használunk a helyes működéshez. Bővebb információt az adatvédelmi szabályzatban olvashatsz. Megértettem