This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random; | |
unsortData = random.sample(range(100), 10) | |
def bubble_sort(List): | |
for j in range(len(List)-1,0,-1): | |
flag = True | |
for i in range(0, j): | |
if List[i] > List[i+1]: | |
flag = False | |
List[i], List[i+1] = List[i+1], List[i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random; | |
unsortData = random.sample(range(100), 10) | |
def selection_sort(L): | |
N = len(L) | |
exchanges_count = 0 | |
for i in range(N-1): | |
min_index = i | |
for j in range(i+1, N): | |
if L[min_index] > L[j]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random; | |
unsortData = random.sample(range(100), 10) | |
def insertion_sort(lst): | |
if len(lst) == 1: | |
return lst | |
for i in range(1, len(lst)): | |
temp = lst[i] | |
j = i - 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* WifiCar.ino | |
* | |
*/ | |
#include <Arduino.h> | |
#include <ESP8266WiFi.h> | |
#include <ESP8266WiFiMulti.h> | |
#include <WebSocketsServer.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int redColor = 0, greenColor = 0, blueColor = 0; // 三色LED燈顏色數值 | |
int rLedPin = 9, gLedPin = 10, bLedPin = 11; // 三色燈在Nano上的數位腳位 | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9600); | |
pinMode(rLedPin, OUTPUT); | |
pinMode(gLedPin, OUTPUT); | |
pinMode(bLedPin, OUTPUT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package holan.tw; | |
import java.awt.Color; | |
import java.awt.Graphics; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import java.awt.event.KeyEvent; | |
import java.awt.event.KeyListener; | |
import javax.swing.JFrame; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
const char* ssid = "your_wifi_ap_ssid"; | |
const char* password = "your_wifi_ap_password"; | |
int ledPin = LED_BUILTIN; | |
WiFiServer server(80); | |
void setup() { | |
Serial.begin(115200); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 程式碼參考來源 https://github.com/SJHOne/MintDuino-Repeat-After-Me-Game | |
*/ | |
#define BUTTON_BASE 2 // 按鈕腳位 2 ~ 4 | |
#define BUZZER_PIN 6 // 蜂鳴器腳位 6 | |
#define LED_BASE 7 // LED 腳位 7 ~ 9 | |
#define WINSTATE 12 // 在一回合中,最多需要回答 12 次的聲音頻率,須為 4 的倍數 | |
#define RESPONSETIME 3000 // 每回合中,回答每個聲音頻率之間的等待時間 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package holan.tw; | |
import java.awt.Color; | |
import java.awt.Graphics; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import java.awt.event.KeyEvent; | |
import java.awt.event.KeyListener; | |
import javax.swing.JFrame; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SoftwareSerial.h> | |
#include <Wire.h> | |
SoftwareSerial CAR_BT(11,12); //定義 PIN11 及 PIN12 分別為 RX 及 TX 腳位 | |
/* Input for leftMotor: | |
IN1 IN2 Action | |
LOW LOW Stop | |
HIGH LOW Forward | |
LOW HIGH Backward |