Arduino DUE: Ano ito, para saan ito ginagamit, at anong mga device ang maaari kong i-develop gamit ang mga board na ito?

Huling pag-update: 14/09/2022
Arduino Due: Ano ito, para saan ito ginagamit, at anong mga device ang maaari kong i-develop gamit ang mga board na ito?

Isa sa mga pinakamalakas na cooktop na magagamit Arduino Ito ang bersyong DUEDahil sa microcontroller, memorya, at bilang ng mga pin nito, isa ito sa mga pinaka-hinahangad kapag kailangan mong magsagawa ng mga kumplikadong proyekto.

Sa kadahilanang ito Inihanda namin ang artikulong ito upang matutunan mo kung para saan ginagamit ang ganitong uri ng plato at ano ang mga pangunahing katangian nito. na iniaalok nito sa mga gumagamit.

Bukod pa rito, ipapaliwanag namin ang mga dapat mong tandaan Kapag gumagamit ng Arduino DUE, ano ang mga pagkakaiba sa development environment para sa pagprograma ng board?. Tignan mo.

Ano ang Arduino DUE at para saan ginagamit ang mga open-source development board na ito?

Arduino DUE Ito ay isang board na nagtatampok ng isang Atmel SAM3X8E microcontroller, nag-aalok ng karagdagang pagganap para sa malalaking proyektoAng pamantayang ito ay sinusuportahan din ng isang mas maraming bilang ng mga digital pin pasukan at labasan at mga analog na pin. Gumagana ito sa boltahe na 3.3V at mayroon 4 port para sa hardware, kung saan 2 ay para sa mga kable Micro USB Ginagamit ang mga ito upang ikonekta ang board sa computer. Maaaring gamitin ang mga operating system ng Arduino Due. Windows, Linux y MacOS.

Mga Katangian ng Arduino DUE: Ano ang mga pinakakawili-wiling katangian nito?

Mga Katangian ng Arduino DUE: Ano ang mga pinakakawili-wiling katangian nito?

Ang mga pangunahing katangian ng Arduino DUE ay:

  • Ang mga sukat nito ay 101,52×53,3mm at may bigat na 36 gramo.
  • Mayroon itong MCU Atmel SAM3X8E ARM Cortex-M3 32-bit na core na gumagana sa 84 MHz.
  • Mayroon itong pasibong memorya 96 KB SRAMGayunpaman, wala itong EEPROM memory tulad ng ibang mga Arduino board. Ang flash memory nito ay 512 KB.
  • Ang boltahe kung saan ito gumagana ay 3Vna may pinakamataas na limitasyon sa pagpasok na 16V.
  • Account na may 54 digital na pin, kung saan 12 ay para sa pulse modulation.
  • Ang mga pin ng Ang mga analog input ay 12 at ang mga aalis, 2.
  • Mayroon itong 2 MicroUSB port, A JTAG, un SPI, dos TWI mga buton para sa pag-reset at pagbura.

Ano ang dapat mong tandaan kapag gumagamit ng Arduino DUE board?

Ang unang bagay na dapat mong tandaan ay ang board na ito ay gumagana sa kasalukuyang intensity na 3.3VNangangahulugan ito na gumagana ito sa mas mataas na boltahe kaysa sa karamihan ng mga 5V na Arduino board. Samakatuwid, dapat kang mag-ingat na huwag masira ang MCU, memorya, at iba pang mga bahagi dahil sa overvoltage.

Isa pang salik na dapat isaalang-alang, bagama't medyo hindi gaanong mahalaga, ay ang laki at bigat nito. Panghuli, Dapat mong isaalang-alang ang lahat ng digital at analog pin na mayroon ka. (ang ibig naming sabihin dito ay ang pangangailangan ng iyong proyekto para sa sakupin lahat ng mga ito, dahil kung mas kaunti ang kailangan, maaari kang pumili ng isa pang mas murang 5V board).

Magkaiba ba ang development environment (Arduino IDE) para sa mga Arduino DUE board?

Magkaiba ba ang development environment (Arduino IDE) para sa mga Arduino DUE board?

El Ang kapaligirang Arduino DUE ay hindi naiiba sa iba pang mga board Kailangan mo lang tandaan na ang IDE ay na-configure para sa Arduino UNO boardSamakatuwid, kakailanganin mong baguhin ang uri ng Arduino sa programa.

Para magawa ito, kakailanganin mong sundin ang mga hakbang na ito:

  • Kapag nabuksan mo na ito IDE pumunta sa Mga tool.
  • Pagkatapos ay piliin ang Palatandaan.
  • Piliin ang pagpipilian DUA.

Mga gamit ng board: Sa anong mga proyekto maaaring gamitin ang Arduino DUE?

Maaari mong gamitin ang Arduino DUE board sa isang malaking bilang ng mga proyekto.

Halimbawa, maaari kang lumikha ng:

  • Isang pedal para baguhin ang tunog ng electric guitar. https://create.arduino.cc/projecthub/electrosmash-team/arduino-due-programmable-guitar-pedal-edfe8b
  • Device upang gumanap mga electrocardiogram. https://create.arduino.cc/projecthub/javiergonzalezb/heart-rate-estimation-using-arduino-due-a2271a
  • Tagabuo ng mga anyong alon. https://create.arduino.cc/projecthub/search?q=due&type=Project

Bukod dito, Kung gusto mong matuto nang detalyado tungkol sa isang proyekto, maaari kang lumikha ng laro ng mga Zero at Cross.Para sa device na ito, kakailanganin mo ng DUE board, controller o 2,8-inch TFT LCD LED touch screen at ang mga kinakailangang kable para sa pag-install.

Kung tungkol sa pagpupulong, kailangan mong gawin ito ayon sa sumusunod na diagram:

Mga gamit ng board: Sa anong mga proyekto maaaring gamitin ang Arduino DUE?

Kapag natapos mo na, kakailanganin mong buksan ang Arduino IDE at isulat ang mga code na ito:

#isama #isama #isama #isama #isama #define TFT_RST 8 #define TFT_DC 9 #define TFT_CS 10 #define TOUCH_ORIENTATION TRANSCAPE Adafruit_ILI9341 tft = Adafruit_ILI9341 (TFT_CS, TFT_DC, TFT_RST); Adafruit_GFX_Buttons [9]; URTouch myTouch (30, 28, 26, 24, 22); unsigned short int moves = 1; unsigned short int winner = 0; unsigned short int x, y; unsigned short int cursor; unsigned short int firstMoves [] = {0, 2, 6, 8}; unsigned short board[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; manlalaro bool; bool b = 1; char start[10] = {"Gametart"}; char you[4] = {"YOU"}; char cpu[4] = {"CPU"}; char again[7] = {"Again?"} };

const unsigned  char  círculo [] PROGMEM = {

0 b0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 ,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,

0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 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x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,

0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0xff,0xff,0xc0,0x1,0xff,0xff,0xe0,0x0,

0x1 , 0xff , 0xff , 0xE0 , 0x1 , 0xff , 0xff , 0xC0 , 0x0 , 0x1 , 0xff , 0xff , 0xF0 , 0x3 , 0xff , 0xff , 0xC0 , 0x0 , 0x0 , 0xff , 0xff , 0xF0 , 0x7 , 0xff , 0xff , 0x80 , 0x0 , 0x0 ,0xff,0xff,0xf8,0x7,0xff,0xff,0x80,0x0,0x0,0x7f,0xff,0xf8,0xf,0xff,0xff,0x0,0x0,

0x0 , 0x3f , 0xff , 0xfc , 0xf , 0xff , 0xfe , 0x0 , 0x0 , 0x0 , 0x3f , 0xff , 0xfe , 0x1f , 0xff , 0xfe , 0x0 , 0x0 , 0x0 , 0x1f , 0xff , 0xfc , 0x1f , 0xff , 0xfc , 0x1f 0x0 , 0x0 , 0x0 ,0x1f,0xff,0xff,0x3f,0xff,0xfc,0x0,0x0,0x0,0xf,0xff,0xff,0x7f,0xff,0xf8,0x0,0x0,

0x0 , 0xf , 0xff , 0xff , 0xff , 0xff , 0xF8 , 0x0 , 0x0 , 0x0 , 0x7 , 0xff , 0xff , 0xff , 0xff , 0xF0 , 0x0 , 0x0 , 0x0 , 0x3 , 0xff , 0xff , 0xff , 0xff , 0xE0 , 0x0 , 0x0 , 0x0 ,0x3,0xff,0xff,0xff,0xff,0xe0,0x0,0x0,0x0,0x1,0xff,0xff,0xff,0xff,0xc0,0x0,0x0,

0x0 , 0x1 , 0xff , 0xff , 0xff , 0xff , 0xC0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff , 0xff , 0xff , 0xff , 0x80 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff , 0xff , 0xff , 0xff , 0x80 , 0x0 , 0x0 , 0x0 ,0x0,0x7f,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0,0x3f,0xff,0xff,0xfe,0x0,0x0,0x0,

0x0 , 0x0 , 0x3f , 0xff , 0xff , 0xfe , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x1f , 0xff , 0xff , 0xFC , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x1f , 0xff , 0xff , 0xFC , 0x0 , 0x0 , 0x0 , 0x0 ,0x0,0x1f,0xff,0xff,0xfc,0x0,0x0,0x0,0x0,0x0,0x3f,0xff,0xff,0xfe,0x0,0x0,0x0,

0x0 , 0x0 , 0x3f , 0xff , 0xff , 0xfe , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x7f , 0xff , 0xff , 0xff , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff , 0xff , 0xff , 0xff , 0x80 , 0x0 , 0x0 , 0x0 ,0x0,0xff,0xff,0xff,0xff,0x80,0x0,0x0,0x0,0x1,0xff,0xff,0xff,0xff,0xc0,0x0,0x0,

0x0 , 0x1 , 0xff , 0xff , 0xff , 0xff , 0xC0 , 0x0 , 0x0 , 0x0 , 0x3 , 0xff , 0xff , 0xff , 0xff , 0xE0 , 0x0 , 0x0 , 0x0 , 0x3 , 0xff , 0xff , 0xff , 0xff , 0xE0 , 0x0 , 0x0 , 0x0 ,0x7,0xff,0xff,0xff,0xff,0xf0,0x0,0x0,0x0,0xf,0xff,0xff,0xff,0xff,0xf8,0x0,0x0,

0x0 , 0xf , 0xff , 0xff , 0xff , 0xff , 0xf8 , 0x0 , 0x0 , 0x0 , 0x1f , 0xff , 0xff , 0x7f , 0xff , 0xfc , 0x0 , 0x0 , 0x0 , 0x1f , 0xff , 0xfc , 0x3f , 0xff , 0xfc , 0x3 0x0 , 0x0 , 0x0 ,0x3f,0xff,0xfc,0x3f,0xff,0xfe,0x0,0x0,0x0,0x3f,0xff,0xfc,0x1f,0xff,0xfe,0x0,0x0,

0x0 , 0x7f , 0xff , 0xF8 , 0x1f , 0xff , 0xff , 0x0 , 0x0 , 0x0 , 0xff , 0xff , 0xF8 , 0xf , 0xff , 0xff , 0x80 , 0x0 , 0x0 , 0xff , 0xff , 0xF0 , 0x7 , 0xff , 0xff , 0x80 , 0x0 , 0x1 ,0xff,0xff,0xe0,0x7,0xff,0xff,0xc0,0x0,0x1,0xff,0xff,0xe0,0x3,0xff,0xff,0xc0,0x0,

0x3 , 0xff , 0xff , 0xC0 , 0x3 , 0xff , 0xff , 0xE0 , 0x0 , 0x3 , 0xff , 0xff , 0xC0 , 0x1 , 0xff , 0xff , 0xE0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 ,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,

0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0

};

configuración vacía () {

myTouch . InitTouch(); akingTouch . setPrecision(PREC_HI); tft. simula(); tft. setRotation (3); tft. fillScreen(ILI9341_BLACK); // Gumuhit ng puting TFT frame. drawRect(0, 0, 320, 240, ILI9341_WHITE); // I-print ang tft na tekstong "Arduino". itakda ang Cursor (80, 30); tft. setTextColor (ILI9341_GREEN); tft. setTextSize(4); tft. print ("Arduino"); // I-print ang tekstong "Tic Tac Toe" tft. itakda ang Cursor (30, 100); tft. setTextColor (ILI9341_WHITE); tft. setTextSize(4); tft. print("Tic Tac Toe"); // Gumawa ng pulang buton // gumawa ng mga buton [0]. initButton(&tft, 160, 200, 200, 40, ILI9341_WHITE, ILI9341_RED, ILI9341_WHITE, start, 2); mga buton[0]. drawButton(); do { maghintay para sa isang tapikin ( & x , & y ); kung ( mga buton [ 0 ). naglalaman ng (x, y)) b = 0; } habang (b > 0); } void loop() { para sa (unsigned short int i = 0; i < 9; i++) { board[i] = 0; } tft. fillScreen(ILI9341_BLACK); // Gumuhit ng puting TFT frame. drawRect(0, 0, 320, 240, ILI9341_WHITE); // I-print ang tekstong "Tic Tac Toe" tft. itakda ang Cursor (30, 30); tft. setTextColor (ILI9341_WHITE); tft. setTextSize(4); tft. print("Tic Tac Toe"); // Nagpi-print ng "YouTube!" Tekstong TFT. itakda ang Cursor (30, 100); tft. setTextColor (ILI9341_GREEN); tft. setTextSize(4); tft. print("Sino ang magsisimula"); // Gumawa ng pulang buton // gumawa ng mga buton [0]. initButton(&tft, 100, 200, 80, 40, ILI9341_WHITE, ILI9341_RED, ILI9341_WHITE, ikaw, 2); mga buton[0]. drawButton(); // lumikha ng mga buton // x, y, w, h, balangkas, punan, mga buton ng teksto[1]. initButton(&tft, 200, 200, 80, 40, ILI9341_WHITE, ILI9341_RED, ILI9341_WHITE, cpu, 2); mga buton[1]. drawButton(); b = 1; gawin { maghintay para sa isang tap(&x, &y); kung(mga buton[0]. naglalaman ng (x, y)) {b = 0; manlalaro = 1; tft. fillScreen(ILI9341_BLACK); // Gumuhit ng puting TFT frame. drawRect(0, 0, 320, 240, ILI9341_WHITE); tft. itakda ang Cursor (30, 30); tft. setTextColor (ILI9341_WHITE); tft. setTextSize(2); tft. print("Ok, magsisimula ka na"); delay(2000); } if(buttons[1]. naglalaman ng (x, y)) {b = 0; manlalaro = 0; tft. fillScreen(ILI9341_BLACK); // Gumuhit ng puting TFT frame. drawRect(0, 0, 320, 240, ILI9341_WHITE); tft. itakda ang Cursor (30, 30); tft. setTextColor (ILI9341_WHITE); tft. setTextSize(2); tft. print("OK, nagsisimula na ang CPU"); delay(2000); } } habang (b > 0); b = 1; gumagalaw = 1; nagwagi = 0; cursor = 10; tft. fillScreen(ILI9341_BLACK); // Gumuhit ng TFT frame. drawRect(0, 0, 320, 240, ILI9341_WHITE); // Gumuhit ng patayong linya tft. fillRect (80, 15, 5, 205, ILI9341_WHITE); tft. fillRect (150, 15, 5, 205, ILI9341_WHITE); // Gumuhit ng pahalang na linya fillRect(15,80,205,5,ILI9341_WHITE); fillRect(15,150,205,5,ILI9341_WHITE); drawRect(230,10,80,220,ILI9341_WHITE); { do { if(moves%2==1 && player==false || moves%2==0 && player==true) { cursor+=10; setCursor(240,cursor); setTextSize(1); println("Nakaguhit ako"); arduinoMove(); checkWinner(); }else { cursor+=10; setCursor(240,cursor); setTextSize(1); println("Ang iyong galaw"); playerMove(); checkWinner(); } delay(1000); moves++; }while (winner==0 && moves<10); waitonetouch(&x,&y); fillScreen(ILI9341_BLACK); //Gumuhit ng frame drawRect(0,0,320,240,ILI9341_WHITE); //I-print ang Tekstong "Tapos na ang Laro" setCursor(50,30); setTextColor(ILI9341_WHITE); setTextSize(4); print("Tapos na ang Laro"); if(winner == 0) { //I-print ang "Gumuhit!" text setCursor(110,100); setTextColor(ILI9341_YELLOW); setTextSize(4); print("DRAW"); } kung(panalo == 1) { //I-print "PANALO ANG TAO!" text setCursor(40,100); setTextColor(ILI9341_BLUE); setTextSize(4); print("PANALO ANG TAO"); } if(winner == 2) { //I-print "PANALO ANG CPU!" text

setCursor(60,100);

setTextColor(ILI9341_RED);

setTextSize(4);

print("CPU WINS");

}

buttons[0].initButton(&tft, 160,200,200,40,ILI9341_WHITE, ILI9341_RED, ILI9341_WHITE,

again, 2);

buttons[0].drawButton();

do{

waitonetouch(&x,&y);

if (buttons[0].contains(x,y))

b=0;

}while(b>0);

}

}

void playerMove()

{

waitonetouch(&x,&y);

if((x>15 && x<85) && (y>15 && y<85))

{

if(board[0]==0)

{

board[0]=1;

drawX(15,15);

}

else error();

}

else if((x>85 && x<155)&& (y>15 && y<85)) //1

{

if(board[1]==0)

{

board[1]=1;

drawX(85,15);

}

else error();

}

if((x>155 && x<225)&& (y>15 && y<85)) //2

{

if(board[2]==0)

{

board[2]=1;

drawX(155,15);

}

else error();

}

if((x>15 && x<85)&& (y>85 && y<155)) //3

{

if(board[3]==0)

{

board[3]=1;

drawX(15,85);

}

else error();

}

si (( x > 85 &&  x < 155 ) &&  ( y > 85  &&  y < 155 ))  // 4

{

si ( tablero [ 4 ] == 0 )

{

tablero [ 4 ] = 1 ;

dibujarX ( 85 , 85 );

}

else error ();

}

if (( x > 155 &&  x < 225 ) &&  ( y > 85  &&  y < 155 ))  // 5

{

if ( tablero [ 5 ] == 0 )

{

tablero [ 5 ] = 1 ;

dibujarX ( 155 , 85 );

}

else error ();

}

si (( x > 15 &&  x < 85 ) &&  ( y > 155  &&  y < 225 ))  // 6

{

si ( tablero [ 6 ] == 0 )

{

tablero [ 6 ] = 1 ;

dibujarX ( 15 , 155 );

}

else error ();

}

if((x>85 && x<155)&& (y>155 && y<225)) //7

{

if(board[7]==0)

{

board[7]=1;

drawX(85,155);

}

else error();

}

if((x>155 && x<225)&& (y>155 && y<225)) //8

{

if(board[8]==0)

{

board[8]=1;

drawX(155,155);

}

else error();

}

}

void error(){

cursor+=10;

setCursor(240,cursor);

setTextSize(1);

println("Error");

delay(1000);

cursor+=10;

setCursor(240,cursor);

println("Try again.");

playerMove();

}

{

if(board[1]==x && board[2]==x && board[0]==y){

if(y==0){

return 0;

}

else return 1;

}

if(board[3]==x && board[6]==x && board[0]==y){

if(y==0){

return 0;

}

else return 6;

}

if(board[0]==y && board[4]==x && board[8]==x){

if(y==0){

return 0;

}

else return 8;

}

if(board[0]==x && board[1]==y && board[2]==x){

if(y==0){

return 1;

}

else return 0;

}

if(board[4]==x && board[7]==x && board[1]==y){

if(y==0){

return 1;

}

de lo contrario, devuelve  7 ;

}

if ( tablero [ 0 ] == x &&  tablero [ 1 ] == x  &&  tablero [ 2 ] == y ) {

si ( y == 0 ) {

volver 2 ;

}

de lo contrario, devuelve  0 ;

}

if ( tablero [ 5 ] == x &&  tablero [ 8 ] == x  &&  tablero [ 2 ] == y ) {

si ( y == 0 ) {

volver 2 ;

}

si no, devuelve  8 ;

}

if ( tablero [ 4 ] == x &&  tablero [ 6 ] == x  &&  tablero [ 2 ] == y ) {

si ( y == 0 ) {

volver 2 ;

}

de lo contrario, devuelve  6 ;

}

if ( tablero [ 4 ] == x &&  tablero [ 5 ] == x  &&  tablero [ 3 ] == y ) {

si ( y == 0 ) {

volver 3 ;

}

si no, devuelve  5 ;

}

if(board[0]==x && board[6]==x && board[3]==y){

if(y==0){

return 3;

}

else return 6;

}

if(board[3]==x && board[4]==y && board[5]==x){

if(y==0){

return 4;

}

else return 3;

}

if(board[1]==x && board[7]==x && board[4]==y){

if(y==0){

return 4;

}

else return 1;

}

if(board[0]==x && board[8]==x && board[4]==y){

if(y==0){

return 4;

}

else return 0;

}

if(board[2]==x && board[6]==x && board[4]==y){

if(y==0){

return 4;

}

else return 2;

}

if(board[3]==x && board[4]==x && board[5]==y){

if(y==0){

return 5;

}

else return 3;

}

if(board[2]==x && board[8]==x && board[5]==y){

if(y==0){

return 5;

}

else return 2;

}

if(board[7]==x && board[8]==x && board[6]==y){

if(y==0){

return 6;

}

else return 8;

}

if(board[0]==x && board[3]==x && board[6]==y){

if(y==0){

return 6;

}

else return 0;

}

if(board[4]==x && board[2]==x && board[6]==y){

if(y==0){

return 6;

}

else return 2;

}

if(board[1]==x && board[4]==x && board[7]==y){

if(y==0){

return 7;

}

else return 1;

}

if(board[6]==x && board[8]==x && board[7]==y){

if(y==0){

return 7;

}

else return 6;

}

if(board[6]==x && board[7]==x && board[8]==y){

if(y==0){

return 8;

}

else return 6;

}

if(board[5]==x && board[2]==x && board[8]==y){

if(y==0){

return 8;

}

else return 2;

}

if(board[4]==x && board[0]==x && board[8]==y){

if(y==0){

return 8;

}

else return 0;

}

else

return 100;

}

void arduinoMove()

{

if(moves<2)

{

do{

unsigned short int randomMove =random(4);

unsigned short int c=firstMoves[randomMove];

if(board[c]==0){

board[c]=2;

drawCpuMove(firstMoves[randomMove]);

return;

}

}while(moves<2);

}

if(moves<3)

{

if(board[4]==0)

{

board[4]=2;

drawCpuMove(4);

return;

}

}

unsigned short int twoPlayer = checkOpponent(2,0);

if(twoPlayer < 9)

{

board[twoPlayer]=2;

drawCpuMove(twoPlayer);

return;

}

unsigned short int nextMove = checkOpponent(1,0);

if(nextMove < 9)

{

board[nextMove]=2;

drawCpuMove(nextMove);

return;

}

unsigned short int next = checkOpponent(0,2);

if(next < 9)

{

board[next]=2;

drawCpuMove(next);

return;

}

do

{

unsigned short int randomMove =random(9);

if (board[randomMove]==0)

{

board[randomMove]=2;

drawCpuMove(randomMove);

return;

}

}while(nextMove == 100);

}

{

drawBitmap(x,y,circle,65,65,ILI9341_RED);

}

{

drawBitmap(x,y,x_bitmap,65,65,ILI9341_BLUE);

}

{

switch(move)

{

case 0: drawCircle(15,15); break;

case 1: drawCircle(85,15); break;

case 2: drawCircle(155,15); break;

case 3: drawCircle(15,85); break;

case 4: drawCircle(85,85); break;

case 5: drawCircle(155,85); break;

case 6: drawCircle(15,155); break;

case 7: drawCircle(85,155);break;

case 8: drawCircle(155,155);break;

}

}

void checkWinner()

{

// noughts win?

kung (board[0]>0 at board[1]==board[0] at board[2]==board[0]) { nagwagi=board[0]; fillRect(15, 45, 205, 5, ILI9341_WHITE); } kung (board[3]>0 at board[4]==board[3] at board[5]==board[3]) { nagwagi=board[3]; fillRect(15, 115, 205, 5, ILI9341_WHITE); } kung (board[6] > 0 at board[7] == board[6] at board[8] == board[6]) { nagwagi = board[6]; tft. fillRect(15, 185, 205, 5, ILI9341_WHITE);} kung(board[0] > 0 at board[3] == board[0] at board[6] == board[0]){panalo = board[0];tft.} fillRect(45, 15, 5, 205, ILI9341_WHITE);} kung(board[1] > 0 at board[4] == board[1] at board[7] == board[1]){panalo = board[1];tft.} fillRect ( 115 , 15 , 5 , 205 , ILI9341_WHITE ); } kung (board[2]>0 at board[5]==board[2] at board[8]==board[2]) { nagwagi=board[2]; fillRect(185, 15, 5, 205, ILI9341_WHITE); } kung (board[0]>0 at board[4]==board[0] at board[8]==board[0]) { nagwagi=board[0]; para sa(unsigned short int xx=0;xx<6;xx++){ drawLine(20+xx, 20, 210+xx, 210, ILI9341_WHITE); } } kung (board[2]>0 at board[4]==board[2] at board[6]==board[2]) { nagwagi=board[2]; para sa(unsigned short int xx=0;xx<6;xx++){ drawLine(210+xx, 20, 20+xx, 210, ILI9341_WHITE); } } } void waitonetouch(unsigned short int *x,unsigned short int *y){ gawin { pagkaantala(10); kung (myTouch. datosMagagamit() == totoo) { myTouch. basahin(); x = akingTouch. getX(); y = akingTouch. getY(); bumalik; } } habang (myTouch. dataAvailable () == false ); }
Mga Ebook ng IPAP
Ebook IPAP

🔥SUMALI🔥 SA BAGONG KOMUNIDAD NG IP@P! MAG-SIGN UP DITO!

Paksa

May-akda: Félix Albornoz

Mayroon akong mahigit 20 taon na karanasan sa pagtatrabaho sa sektor ng teknolohiya, pagtulong sa mga kumpanya at mga gumagamit na umunlad at magsanay sa larangang ito. Palagi akong natututo ng mga bagong bagay.

Kaugnay