void main() { char key[17],i; for(i=0;i<16;i++) { key[i]='*'; } key[17]=0; while(1) { //lcd(key); //lcd("#n%d ",_sdat_in); lcd("#n%d ",_key); if(sw1()==0) { beep_b(4); sleep(100); for(i=0;i<16;i++) { key[i]= uart_getkey(); } key[17]=0; lcd(key); } } }
void semiCorrect() { if(Center_white_line<40) { if(Left_white_line>40 && Right_white_line<40) //bww { lcd("bww"); while(Center_white_line<40 && Left_white_line>40 && Right_white_line<40) { left(); set_color(); } lcd("-"); } else if(Right_white_line>40 && Left_white_line<40) //wwb { lcd("wwb"); while(Center_white_line<40 && Left_white_line<40 && Right_white_line>40) { right(); set_color(); } lcd("-"); } } }
int main() { Lcd lcd(Lcd_RS, Lcd_E, Lcd_DB7, Lcd_DB6, Lcd_DB5, Lcd_DB4); lcd(0) << "aaaabb" << endl; lcd(1) << "aaaabb" << endl; while(1) time.msleep(1000); }
/********************************************************************* * Set X Address (Col: 0-13) *********************************************************************/ void lcd_setx(int x) { int setx = (x * 6) | 0x80; lcd(LCD_Command); lcd_wr_byte(setx); lcd(LCD_Unselect); lcd_x = x; }
/********************************************************************* * Set Y Address (Row: 0-5) *********************************************************************/ void lcd_sety(int y) { int sety = 0x40 | (y & 0x07); lcd(LCD_Command); lcd_wr_byte(sety); lcd(LCD_Unselect); lcd_y = y; }
/* * Internal - restore the cursor: */ static void lcd_restore(void) { int sety = 0x40 | (lcd_y & 0x07); int setx = (lcd_x * 6) | 0x80; lcd(LCD_Command); lcd_wr_byte(sety); lcd_wr_byte(setx); lcd(LCD_Unselect); }
void main() { int i; for(i=10;i>0;i--) { lcd("Count: %d ",i); sleep(1000); } lcd("Count: %d ",i); }
/* * Internal - put one text character to LCD device */ static void lcd_putraw(char c) { const uchr_t *fc = lcd_fontchr(c); /* Locate font cell */ int x; lcd(LCD_Data); /* Start LCD data mode */ for ( x=0; x<5; ++x ) lcd_wr_byte(*fc++); /* Send font bytes 0-4 */ lcd_wr_byte(0x00); /* And one blank cell */ lcd(LCD_Unselect); }
void pick(int side) //TODO delay { if(side==0) lcd("pickRight"); else lcd("pickLeft"); elevate(0, side);//lower open(side); close(side); elevate(45, side);//mid armCount--; }
void drop(int side) //TODO delay { if(side==0) lcd("dropRight"); else lcd("dropLeft"); elevate(0, side);//lower open(side); elevate(45, side);//mid close(side); armCount++; }
void drop(int side) { lower(side);//lower open(side); elevate();//mid armCount++; if(side==0) lcd("dropRight"); else lcd("dropLeft"); }
/********************************************************************* * Set y,x : *********************************************************************/ void lcd_move(int y,int x) { int sety = 0x40 | (y & 0x07); int setx = (x * 6) | 0x80; lcd(LCD_Command); lcd_wr_byte(sety); lcd_wr_byte(setx); lcd(LCD_Unselect); lcd_y = y; lcd_x = x; }
/********************************************************************* * Clear to end of line : *********************************************************************/ void lcd_clrtoeol(void) { int x, z; lcd(LCD_Data); for ( x=lcd_x; x<lcd_cols; ++x ) { for ( z=0; z<6; ++z ) lcd_wr_byte(0x00); lcd_buf[lcd_y][x] = ' '; } lcd(LCD_Unselect); lcd_restore(); }
void pick(int side) { lower(side);//lower open(side); close(side); elevate();//mid armCount--; if (side == 0) lcd("pickRight"); else lcd("pickLeft"); }
/********************************************************************* * Configure LCD GPIO Pins and Initialize LCD * * Note: * The LCD units vary in their ideal setting for Vop. Here the * default value used is 0xBF, if the arg vop is <= 0. Good * values vary from about 0xB0 all the way up to 0xE0. * * Hints: * 1. If you see a matrix of dark pixels, your Vop is too high. * 2. If you see faint or no pixels, increase Vop. * 3. For inverse video, readjust Vop to suit. * 4. Type '+' or '-' to try different Vop values. Press * + or - repeatedly until the contrast improves. * *********************************************************************/ void lcd_init(int vop) { if ( vop > 0 ) lcd_vop = vop; /* Use this new value */ /* No outputs yet.. */ gpio_config(lcd_ce,Input); gpio_config(lcd_res,Input); gpio_config(lcd_d_c,Input); gpio_config(lcd_sdin,Input); gpio_config(lcd_sclk,Input); /* Configure all pins as high */ gpio_write(lcd_ce,1); gpio_write(lcd_res,1); gpio_write(lcd_d_c,1); gpio_write(lcd_sdin,1); gpio_write(lcd_sclk,1); /* Now assert outputs */ gpio_config(lcd_ce,Output); gpio_config(lcd_res,Output); gpio_config(lcd_d_c,Output); gpio_config(lcd_sdin,Output); gpio_config(lcd_sclk,Output); lcd(LCD_Command); /* Command mode */ gpio_write(lcd_res,0); /* Apply /RESET */ gpio_read(lcd_res); /* Delay a little */ gpio_read(lcd_res); /* Delay a little */ gpio_read(lcd_res); /* Delay a little */ gpio_write(lcd_res,1); /* Deactivate /RESET */ gpio_read(lcd_res); /* Delay a little more */ gpio_read(lcd_res); /* Delay a little */ gpio_read(lcd_res); /* Delay a little */ lcd_wr_byte(0x21); /* Chip Active, Extended instructions enabled */ lcd_wr_byte(lcd_vop); /* Set Vop level */ lcd_wr_byte(0x04); /* Set TC */ lcd_wr_byte(0x14); /* Set Bias */ lcd_wr_byte(0x20); /* Chip Active, Extended instructions disabled */ lcd_wr_byte(0x0C); /* Set normal mode (adjust Vop if using inverse video) */ lcd(LCD_Unselect); lcd_clear(); /* Clear screen */ }
int main() { PCD8544 lcd(&STM32::SPI::SPI1, PIN_B1, 4000000, PIN_B2, 3, 2, 68); lcd.print(0, 0, PCD8544::defaultFont, false, (char*)"Hello, World!"); while (true); }
void terminalCheck1() { if (ct != ot) { if (((ct == 0 || ct == 1) && dir == 2) || ((ct == 2 || ct == 3) && dir == 0)) back(); else front(); ot = ct; } turnRight(); term[ct][0]=scan(); lcd_print(1,1,1111,4); //printf("Enter term[%d][%d]\n", ct, 0); //scanf("%d", &term[ct][0]); lcd((char*)term[ct][0]); if (term[ct][0] == -1 || term[ct][0] == color[ct]) total--; }
void main() { char left,right; lcd("Press SW1"); sw1_press(); while(1) { left = in_d(0); right = in_d(1); if(left==1 && right==1) { forward(10); } else if(left==0 && right==1) { backward(1000); turn_right(800); } else if(left==1 && right==0) { backward(1000); turn_left(800); } else if(left==0 && right==0) { backward(1000); turn_left(1500); } } }
void turn() //turn robo by 180 degree { if (dir == 0 && (ot == 2 || ot == 3)) { velocity(turn_v, turn_v); left_degrees(180); } else if (dir == 2 && (ot == 0 || ot == 1)) { velocity(turn_v, turn_v); left_degrees(180); } else { velocity(turn_v, turn_v); left_degrees(150); while (ADC_Conversion(2)<70) left(); stop(); } lcd("turn"); //_delay_ms(2000); dir = (dir + 2) % 4; //printf("Turn\n"); angle += 180; }
int main() { MBED_HOSTTEST_TIMEOUT(15); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(SPI C12832 display); MBED_HOSTTEST_START("MBED_35"); C12832 lcd(D11, D13, D12, D7, D10); // clear the screen lcd.cls(); // print the first line and wait 3 sec lcd.locate(0,3); lcd.printf("mbed application board!"); // print the counter prefix; the number will be printed in the while loop lcd.locate(0,15); lcd.printf("Counting:"); int i=1, j=0; while(i++,i<=200) { lcd.locate(42,15); lcd.printf("%d", i); if (i % 50 == 0) { lcd.invert(j = j ? 0 : 1); }; wait(0.001); } MBED_HOSTTEST_RESULT(1); }
void loop() { Bluetooth(); Serial.print("CMSET:"); Serial.print(cmset); Serial.println("cm"); Serial.println(); delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings. unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS). Serial.print("Ping: "); cm=uS / US_ROUNDTRIP_CM; Serial.print("high:"); Serial.print(cm); // Convert ping time to distance and print result (0 = outside set distance range, no ping echo) Serial.println("cm"); //val=analogRead(potpin);// 读取传感器的模拟值并赋值给val //Serial.println(val);//显示val 变量 //pwmval=val/4; PID(); analogWrite(pwmpin,tempctrl);// 输出PWM(PWM 输出最大值255) Serial.print ("pwmval:"); Serial.println (tempctrl); Serial.println (); delay(500);//延时0.01 秒 lcd(); }
void main() { unsigned int left,mid,right; lcd("Press SW1"); sw1_press(); while(1) { left = analog(0); mid = analog(1); right = analog(2); if(left<REF && mid>REF && right<REF) { forward(10); } else if(left>REF && mid<REF && right<REF) { turn_left(10); } else if(left<REF && mid<REF && right>REF) { turn_right(10); } else if(left>REF && mid>REF && right>REF) { pause(); sleep(3000); forward(500); } } }
void operatorControl() { lcdInitiate(); while (true){ ch3 = joystickAxes(3); ch1 = joystickAxes(1); drive(ch3, ch1); // lift code lift(); // pincer code pincers(); lcd(); delay(100); if(joystickGetDigital(2,7,JOY_DOWN)){ motorSet(left_lift_Motor1, -127); delay(2000); motorSet(left_lift_Motor1, 0); motorSet(left_lift_Motor2, 127); delay(2000); motorSet(left_lift_Motor2, 0); motorSet(right_lift_Motor3, -127); delay(2000); motorSet(right_lift_Motor3, 0); motorSet(right_lift_Motor4, 127); delay(2000); motorSet(right_lift_Motor4, 0); } } }
int main() { int testCases; scanf("%d", &testCases); for (int testCase = 1; testCase <= testCases; testCase++) { printf("Case #%d: ", testCase); long long int N; int Pd, Pg; scanf("%lld %d %d", &N, &Pd, &Pg); if ((Pd < 100 && Pg == 100) || (Pd > 0 && Pg == 0)) { printf("Broken"); } else if (Pd == 0 || N > 100) { printf("Possible"); } else { int solved = -1; long long int n = Pd; long long int d = 100; //printf("----%d %d %d\n", N, Pd, Pg); while (int div = lcd(n, d)) { n /= div; d /= div; //printf("%d %d %d\n", div, n, d); } if (d <= N) printf("Possible"); else printf("Broken"); } printf("\n"); } return 0; }
/* Configuración de pines de entrada/salida */ void setup() { TRISB=0; //defino PORTB como salida PORTB=0; PORTD=0; pinmode(ICR_DIG1,INPUT); pinmode(ICR_DIG2,INPUT); /* si se activa el sensor de ultra sonido, funciona como salida*/ pinmode(ICR_DIG3,TRIG); pinmode(ICR_DIG4,ECHO); pinmode(ICR_l293_P1,OUTPUT); pinmode(ICR_l293_P2,OUTPUT); pinmode(ICR_l293_P3,OUTPUT); pinmode(ICR_l293_P4,OUTPUT); ServoAttach(ICR_SRV1); ServoAttach(ICR_SRV2); ServoAttach(ICR_SRV3); ServoAttach(ICR_SRV4); ServoAttach(ICR_SRV5); #if defined(__USART__) serial_begin(9600); Delayms(1000); #endif #if defined(__LCD__) //Uso el PORTB para el LCD (usando los primeros 4bits y los // otros dos para RS y E lcd(4, 5, 0, 1, 2, 3, 0, 0, 0, 0); // RS, E, D4 ~ D8 // Defino el numero de columnas y filas del LCD: begin(8, 2); home(); #endif }
int main() { int t,n,i,j,ans,flag; t=scan(); while(t--) { ans=-1; n=scan(); for(i=0;i<n;i++) { a[i]=scan(); if(a[i]==1) { flag=1; } } if(flag==1) { printf("-1\n"); continue; } if(n==1) { for(i=2;i<=a[0];i++) { if(a[0]%i==0) { break; } } printf("%d\n",i); continue; } ans=lcd(a[0],a[1]); for(i=1;i<n;i++) { ans=lcd(ans,a[i]); if() } printf("%d\n",ans); } return 0; }
void newSort() { lcd("other sort"); int t1, t2, a1, a2; if (arm[0] != -1) a1 = indicator[arm[0]]; if (arm[1] != -1) a2 = indicator[arm[1]]; t1 = (ct + 1) % 2; t2 = t1 + 2; if (arm[0] != -1 || arm[1] != -1) { ct = a1; if (arm[0] != -1 && (term[a1][0] == -1 || term[a1][1] == -1)) { if (arm[1] == -1) { if (sort[t1] == color[t1] || sort[t1] == color[t2]) pickSort(1, a1); } } else if (arm[1] != -1 && (term[a2][0] == -1 || term[a2][1] == -1)) { ct = a2; if (term[a2][0] == -1 || term[a2][1] == -1) { if (arm[0] == -1) { if (sort[t1] == color[t1] && sort[t1] == color[t2]) pickSort(1, t1); } } else if (sort[t1] == -1 && arm[0] != -1) sortDrop(1, t1); } else if (arm[0] != -1 && (sort[t1] == -1 && arm[1] != -1)) sortDrop(1, t1); else if (arm[0] != -1) ct = arm[0]; else ct = arm[1]; } else { if ((sort[t1] == color[t1] || sort[t1] == color[t2]) && sort[t1] != -1) ct = indicator[sort[t1]]; else if (sort[t1] != -1) { pickSort(0, t1); ct = (t1 + 1) % 2 + 4; } else if (visited[t1] == 1 && (term[t1][0] == color[t1] || term[t1][0] == -1) && (term[t1][1] == color[t1] || term[t1][1] == -1)) ct = t2; else ct = t1; } adj = adjCount(ct); }
void main() { while(1) { lcd("Switch: %d ",in_a(0)); sleep(10); } }
void main() { while(1) { lcd("L %d M %d R %d ",analog(0),analog(1),analog(2)); sleep(100); } }
void drop(int side) //TODO delay { lcd("drop"); elevate(0, side);//lower open(side); elevate(45, side);//mid close(side); armCount++; }