Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:c862449fe089, committed 2016-04-04
- Comitter:
- hainjedaf
- Date:
- Mon Apr 04 20:59:46 2016 +0000
- Child:
- 1:85d249817f55
- Commit message:
- werkt niet;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PCF8574.lib Mon Apr 04 20:59:46 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/simon/code/PCF8574/#ec8da0c59403
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Apr 04 20:59:46 2016 +0000
@@ -0,0 +1,91 @@
+/*
+ * Naam: PCF8574_ButtonPress
+ *
+ * Omschrijving:
+ * I2C testprogramma:
+ * -Configureer PCF8574 4x OUT, 4x IN.
+ * -Zet alle PCF8574-Leds aan en geef terminal echo.
+ * -Zet alle PCF8574-Leds uit en geef terminal echo.
+ * -Zet led 2 aan ten teken 'Initialisatie Klaar' en geef terminal echo.
+ * -Als PCF8574-Knop# ingedrukt: PCF8574-Led# aan
+ * -Als PCF8574-Knop# losgelaten: PCF8574-Led# uit.
+ *
+ * Aanmaakdatum: 04 april 2016
+ *
+ * Geschreven door: Marout Yasuo Sluijter-Borms
+ *
+ * Copyright (c) 2016, MYSB, The Manhattan Project
+ * Zie einde programma / See end of program.
+ */
+
+/* Libraries en classes insluiten */
+#include "mbed.h"
+#include "PCF8574.h"
+
+/* Definieer seriële poorten */
+Serial pc(USBTX, USBRX); // tx, rx communicatie met PC terminal via USB.
+I2C i2c_bus( p9, p10); // I2C bus.
+PCF8574 pcf0( p9, p10, 0x70); // Eerste PCF8574 chip
+PCF8574 pcf1( p9, p10, 0x72); // Tweede PCF8574 chip
+
+
+/* Definieer digitale IO */
+DigitalOut led(LED2); // Led 2 op mbed is signaal 'Initialisatie klaar'.
+
+/* Definieer Analoge IO */
+
+/* Definieer globale variabelen */
+char DataIn; // Data ingelezen van PCF8574
+char DataOut; // Data te schrijven naar PCF8574
+
+/* Definieer globale constanten */
+// const int chipaddress = 0x40; // Adres van de PCF8574
+const int i2c_speed = 400000; // Bussnelheid 400kHz
+const int baudrate = 38400; // Baudrate communicatie met terminal
+
+/* Start hoofprogramma */
+
+int main()
+{
+// pc.baud(baudrate); // stel baudrate in van usb serial
+ pc.printf("\x1B\x48\x1B\x4A\r"); // scherm schoon en cursor linksboven
+ pc.printf("PCF8574A als bidirectionele IO\n\r");
+
+ i2c_bus.frequency( i2c_speed); // Zet de I2C bus op 400kHz
+
+ pc.printf("Zet I2C speed op %d Hz.\n\r", i2c_speed); // echo naar de terminal
+
+ while (1)
+ {
+ DataOut = 0xF0;
+// pcf0.write(DataOut);
+ DataIn = pcf0.read(); // lees eerste chip uit
+ pc.printf("Waaarde van inputs: %d.\r\n", DataIn); // echo gelezen data naar terminal
+ wait ( 0.2);
+ DataOut = DataIn >> 4; // Shift DataIn 4 plaatsen rechts
+ pc.printf("Waaarde van outputs: %d.\r\n", DataOut); // echo gemodificeerde data naar terminal
+ wait ( 0.2);
+ pcf0.write(DataOut);
+ } // endwhile
+
+} // endmain
+
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Apr 04 20:59:46 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5 \ No newline at end of file