<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Clock</id>
		<title>Clock - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Clock"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Clock&amp;action=history"/>
		<updated>2026-06-06T05:20:39Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Clock&amp;diff=2920&amp;oldid=prev</id>
		<title>Pkj：Created page with &quot;{| style=&quot;width: 800px;&quot; |- | ==Objective==  The course will show you how to use Processing to display a Microduino clock.   ==Equipment== *'''Microduino-Core''' *'''Mic...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Clock&amp;diff=2920&amp;oldid=prev"/>
				<updated>2014-06-06T08:42:38Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective==  The course will show you how to use Processing to display a Microduino clock.   ==Equipment== *&amp;#039;&amp;#039;&amp;#039;&lt;a href=&quot;/index.php/Microduino-Core&quot; title=&quot;Microduino-Core&quot;&gt;Microduino-Core&lt;/a&gt;&amp;#039;&amp;#039;&amp;#039; *&amp;#039;&amp;#039;&amp;#039;Mic...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Objective==&lt;br /&gt;
&lt;br /&gt;
The course will show you how to use Processing to display a Microduino clock. &lt;br /&gt;
&lt;br /&gt;
==Equipment==&lt;br /&gt;
*'''[[Microduino-Core]]'''&lt;br /&gt;
*'''[[Microduino-FT232R]]'''&lt;br /&gt;
*'''[[Microduino-RTC]]'''&lt;br /&gt;
&lt;br /&gt;
*Other Hardware Equipment &lt;br /&gt;
**A USB cable  &lt;br /&gt;
&lt;br /&gt;
==Schematic==&lt;br /&gt;
&lt;br /&gt;
Just stack the three Microduino modules needed together&lt;br /&gt;
&lt;br /&gt;
==Program==&lt;br /&gt;
&lt;br /&gt;
Referring to ProcessingColock&lt;br /&gt;
&lt;br /&gt;
MicroduinoColock&lt;br /&gt;
&lt;br /&gt;
==Debugging==&lt;br /&gt;
&lt;br /&gt;
Step 1：Build the hardware environment on the basis of the schematic, as follows: &lt;br /&gt;
[[File:processingColockConnectionDiagram.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Step 2：Here the code needed: &lt;br /&gt;
&lt;br /&gt;
The code of the two ends (Processing and Microduino) &lt;br /&gt;
&lt;br /&gt;
Microduino:&lt;br /&gt;
&lt;br /&gt;
//Just run the RTC module and transmit time data to the serial port&lt;br /&gt;
  void loop()&lt;br /&gt;
  {&lt;br /&gt;
    rtc.formatDate();&lt;br /&gt;
    rtc.formatTime();&lt;br /&gt;
    //send time data to port&lt;br /&gt;
    Serial.print(rtc.getHour());&lt;br /&gt;
    Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
    Serial.print(rtc.getMinute());&lt;br /&gt;
    Serial.print(&amp;quot;:&amp;quot;);&lt;br /&gt;
    Serial.println(rtc.getSecond());&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
//Initialize time&lt;br /&gt;
  //inital time&lt;br /&gt;
  void vosettime()&lt;br /&gt;
  {&lt;br /&gt;
    //rtc.initClock();&lt;br /&gt;
    //day, weekday, month, century(1=1900, 0=2000), year(0-99)&lt;br /&gt;
    rtc.setDate(4, 1, 6, 0, 14);&lt;br /&gt;
    //hr, min, sec&lt;br /&gt;
    rtc.setTime(15, 28, 50);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Processing:&lt;br /&gt;
&lt;br /&gt;
//Define the first serial data after getting it, and cache it if there is a new line&lt;br /&gt;
  // List all the available serial ports in the output pane.&lt;br /&gt;
  // You will need to choose the port that the Wiring board is&lt;br /&gt;
  // connected to from this list. The first port in the list is&lt;br /&gt;
  // port #0 and the third port in the list is port #2.&lt;br /&gt;
  println(Serial.list());&lt;br /&gt;
  // Open the port that the Wiring board is connected to (in this case #0)&lt;br /&gt;
  // Make sure to open the port at the same speed Wiring is using (9600bps)&lt;br /&gt;
  port = new Serial(this, Serial.list()[0], 9600);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//Initialize the center point position of the clock as well as the length of the hour hand, minute hand and the second hand  &lt;br /&gt;
  int radius = min(width, height)/2;&lt;br /&gt;
  secR = radius * 0.72;&lt;br /&gt;
  minR = radius * 0.60;&lt;br /&gt;
  hourR = radius * 0.50;&lt;br /&gt;
  clockDiameter = radius * 1.8;&lt;br /&gt;
  cx = width /2 ;&lt;br /&gt;
  cy = height /2 ;&lt;br /&gt;
&lt;br /&gt;
//Draw the current value after getting the x-coordinate value of the mouse via serial output &lt;br /&gt;
  void update(int x) &lt;br /&gt;
  {&lt;br /&gt;
    port.write(x);&lt;br /&gt;
    stroke(255);  &lt;br /&gt;
    line(mouseX, 0, mouseX, 160);   &lt;br /&gt;
    text (mouseX, mouseX, 180);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//Receive the serial data and process time information&lt;br /&gt;
    //split data by &amp;quot;:&amp;quot;&lt;br /&gt;
    String time[]=val.split(&amp;quot;:&amp;quot;); &lt;br /&gt;
    //if some exception happend, initial time is 0 colock&lt;br /&gt;
    try {&lt;br /&gt;
      hour=Integer.parseInt(time[0]);&lt;br /&gt;
      minute=Integer.parseInt(time[1]);&lt;br /&gt;
      second=Integer.parseInt(time[2]);&lt;br /&gt;
    } &lt;br /&gt;
    catch (NumberFormatException e) {&lt;br /&gt;
      hour=0;&lt;br /&gt;
      minute=0;&lt;br /&gt;
      second=0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
//Draw a clock&lt;br /&gt;
    float s = map(second, 0, 60, 0, TWO_PI) - HALF_PI;&lt;br /&gt;
    float m = map(minute+norm(second, 0, 60), 0, 60, 0, TWO_PI)- HALF_PI;&lt;br /&gt;
    float h = map(hour+norm(minute, 0, 60), 0, 24, 0, TWO_PI * 2 ) - HALF_PI;&lt;br /&gt;
    //draw clock&lt;br /&gt;
    stroke(255, 250, 0);&lt;br /&gt;
    strokeWeight(1);&lt;br /&gt;
    line(cx, cy, cx + cos(s) * secR, cy + sin(s) * secR);&lt;br /&gt;
    strokeWeight(2);&lt;br /&gt;
    line(cx, cy, cx+ minR * cos(m), cy + minR * sin(m));&lt;br /&gt;
    strokeWeight(4);&lt;br /&gt;
    line(cx, cy, cx + hourR * cos(h), cy + hourR * sin(h));&lt;br /&gt;
    strokeWeight(2);&lt;br /&gt;
    stroke(255, 0, 0);&lt;br /&gt;
    for (int a = 0 ;a&amp;lt;360;a+=6) {&lt;br /&gt;
      float angle =  radians(a);&lt;br /&gt;
      float cx1 =  (secR+20) * cos(angle);&lt;br /&gt;
      float cy1 =  (secR+20) * sin(angle);&lt;br /&gt;
      point(cx + cx1, cy + cy1);&lt;br /&gt;
      if (a%30==0) {&lt;br /&gt;
        line(cx+cx1, cy+cy1, cx+cx1*0.98, cy+cy1*0.98);&lt;br /&gt;
        fill(255);&lt;br /&gt;
        int mark;&lt;br /&gt;
        if (a/30&amp;gt;9) {&lt;br /&gt;
          mark = a/30 -9;&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        { &lt;br /&gt;
          mark = a/30 +3;&lt;br /&gt;
        }&lt;br /&gt;
        text(mark, cx+cx1*1.05-5, cy+cy1*1.05+5);&lt;br /&gt;
      }&lt;br /&gt;
      fill(90, 155, 11);&lt;br /&gt;
      text(hour+&amp;quot;:&amp;quot;+minute+&amp;quot;:&amp;quot;+second, cx-25, cy+100);&lt;br /&gt;
      text(&amp;quot;Microduino&amp;quot;, cx-25, cy-100);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Step 3：Download the code and get it complied successfully. &lt;br /&gt;
&lt;br /&gt;
Step 4：Focus on Processing after the system goes well. &lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
&lt;br /&gt;
A running clock will be displayed on the screen, just like this&lt;br /&gt;
[[File:processingColockResult.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pkj</name></author>	</entry>

	</feed>