// לימוד שפת סי , בסביבת ארדואינו קורס C506
// רובוטרוניקס מפתחת תוכנה ואלקטרוניקה - משדרים כרטיסים אלקטרונים
// קורסים למהנדסים , בתי ספר , ונוער
#include <stdio.h>
#include <string.h>
void setup() {
char buf[100]; //1-D
char x[3][3]; //2-D
int c,r; // r - row , c -column
int SumCells =0;
Serial.begin(9600);
x[0][0]=1;
x[0][1]=0;
x[0][2]=1;
x[1][0]=0;
x[1][1]=1;
x[1][2]=0;
x[2][0]=1;
x[2][1]=0;
x[2][2]=1;
Serial.println("Array 2-D - multiply by Constance ");
delay(1000);
for(r=0;r<=2;r++) // row index
{
for(c=0;c<=2;c++) // column
{
x[r][c] =x[r][c]*10;
Serial.print(x[r][c],DEC);
Serial.print(" ");
delay(100); // 150 ms -- ? 1/8 sec
SumCells = SumCells + x[r][c];
}
Serial.println(); // new line
}
Serial.println("Total cells of all array : ");
Serial.print(SumCells,DEC);
Serial.println(); // new line
Serial.println(); // new line
Serial.println("Array 2-D - all array ");
delay(1000);
for(r=0;r<=2;r++) // row index
{
for(c=0;c<=2;c++) // column
{
Serial.print(x[r][c],DEC);
Serial.print(" ");
delay(100); // 150 ms -- ? 1/8 sec
}
Serial.println(); // new line
}
SumCells =0;
Serial.println("Array 2-D - Alachson Rashi");
delay(500);
for(r=0;r<=2;r++) // row index
{
for(c=0;c<=2;c++) // column
{
if( r==c)
{
Serial.print(x[r][c],DEC);
delay(100); // 150 ms -- ? 1/8 sec
SumCells = SumCells + x[r][c];
}
else
{
Serial.print(" ");
}
}
Serial.println(); // new line
}
Serial.println("Total cells of all array : ");
Serial.print(SumCells,DEC);
Serial.println(); // new line
Serial.println(); // new line
Serial.println("Array 2-D - Alachson Mishnei");
delay(500);
for(r=0;r<=2;r++) // row index
{
for(c=0;c<=2;c++) // column
{
if( r==(2-c ) )
{
Serial.print(x[r][c],DEC);
delay(100); // 150 ms -- ? 1/8 sec
}
else
{
Serial.print(" ");
}
}
Serial.println(); // new line
}
Serial.println("Array 2-D - RAW 1 ONLY");
delay(500);
for(r=0;r<=2;r++) // row index
{
for(c=0;c<=2;c++) // column
{
if( r==1 )
{
Serial.print(x[r][c],DEC);
delay(100); // 150 ms -- ? 1/8 sec
}
else
{
Serial.print(" ");
}
}
Serial.println(); // new line
}
Serial.println("Array 2-D - col 1 ONLY");
delay(500);
for(r=0;r<=2;r++) // row index
{
for(c=0;c<=2;c++) // column
{
if( c==2 )
{
Serial.print(x[r][c],DEC);
delay(100); // 150 ms -- ? 1/8 sec
}
else
{
Serial.print(" ");
}
}
Serial.println(); // new line
}
}
void loop() {
// put your main code here, to run repeatedly:
}