一区二区三区三上|欧美在线视频五区|国产午夜无码在线观看视频|亚洲国产裸体网站|无码成年人影视|亚洲AV亚洲AV|成人开心激情五月|欧美性爱内射视频|超碰人人干人人上|一区二区无码三区亚洲人区久久精品

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

怎樣使用RFID RC-522和Arduino創(chuàng)建一個(gè)簡(jiǎn)單的超市應(yīng)用程序

454398 ? 來(lái)源:網(wǎng)絡(luò)整理 ? 作者:網(wǎng)絡(luò)整理 ? 2019-11-25 15:59 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

步驟1:設(shè)置ArduinoRFID RC-522(物理連接)

怎樣使用RFID RC-522和Arduino創(chuàng)建一個(gè)簡(jiǎn)單的超市應(yīng)用程序

只需將arduino與RFID連接-RC522,如上圖所示。

警告:僅提供3.3V電壓,否則模塊將燒壞

為Uno/Nano和Mega插腳 strong》

RC522 MODULE Uno/Nano MEGA

SDA D10 D9

SCK D13 D52

MOSI D11 D51

MISO D12 D50

IRQ N/A N/A

GND GND GND

RST D9 D8

3.3V 3.3V 3.3V

第2步:Arduino代碼。

復(fù)制以下代碼,然后將其上傳到您的Arduino

/*

PINOUT:

RC522 MODULE Uno/Nano MEGA

SDA D10 D9

SCK D13 D52

MOSI D11 D51

MISO D12 D50

IRQ N/A N/A

GND GND GND

RST D9 D8

3.3V 3.3V 3.3V

*/

/* Include the standard Arduino SPI library */

#include

/* Include the RFID library */

#include

/* Define the DIO used for the SDA (SS) and RST (reset) pins. */

#define SDA_DIO 9

#define RESET_DIO 8

/* Create an instance of the RFID library */

RFID RC522(SDA_DIO, RESET_DIO);

int reader=0;

void setup()

{

Serial.begin(9600);

/* Enable the SPI interface */

SPI.begin();

/* Initialise the RFID reader */

RC522.init();

}

void loop()

{

/* Temporary loop counter */

byte i;

/* Has a card been detected? */

if (RC522.isCard())

{

/* If so then get its serial number */

RC522.readCardSerial();

/* Output the serial number to the UART */

for(i = 0; i 《= 2; i++)

{

Serial.print(RC522.serNum[i],DEC);

//Serial.print(RC522.serNum[i],HEX);

}

Serial.print(“,”);

Serial.print(reader++);

Serial.println();

}

delay(1000);

}

步驟3:設(shè)置MySQL

為MySQL安裝Wamp服務(wù)器并將其配置為存儲(chǔ)數(shù)據(jù)(

運(yùn)行wamp服務(wù)器打開(kāi)MySQL控制臺(tái)

選擇數(shù)據(jù)庫(kù)

然后為您的數(shù)據(jù)創(chuàng)建表

create table rfid(ID int(8),token int(1),Name varchar(20),Amount int(4));

現(xiàn)在查看此鏈接以了解如何獲取您的RFID標(biāo)簽值,然后使用以下代碼插入數(shù)據(jù)。不要忘記將ID值替換為您的RFID標(biāo)簽值

insert into rfid values(3756178,1,‘Pencil’,20);

使用令牌值作為 1 ,以便在首次讀取標(biāo)簽值后,它將自動(dòng)更改為 2 讀取未插入數(shù)據(jù)庫(kù)的卡時(shí),不要使用 0 作為令牌值,它將分配0,然后將其顯示為“未知卡”。

步驟4:設(shè)置處理IDE

下載并安裝處理IDE 2.2.1

將上述給定的ZIP提取到MyDocuments/Processing/Libraries

現(xiàn)在打開(kāi)處理的IDE,并檢查庫(kù)是否正確安裝(如上圖所示)

然后復(fù)制以下代碼進(jìn)行處理并自行命名

import de.bezier.data.sql.*;

import processing.serial.*;

//import java.math.BigInteger;

// created 2005-05-10 by fjenett

// updated fjenett 20080605

MySQL dbconnection;

String s=“ ”;

int Wheight=700;

int Wwidth=1200;

long ID;

int token;

int Amount;

int Total=0;

String[] a={“NULL”,“NULL”};

int end = 10; // the number 10 is ASCII for linefeed (end of serial.println), later we will look for this to break up individual messages

String serial; // declare a new string called ‘serial’ 。 A string is a sequence of characters (data type know as “char”)

Serial port;

String curr,prev,Name;

PFont f;

void setup()

{

//size( Wwidth,Wheight );

size(700,500);

f=createFont(“Arial”,24,true);

// this example assumes that you are running the

// mysql server locally (on “l(fā)ocalhost”)。

//

// replace --username--, --password-- with your mysql-account.

//

String user = “root”;

String pass = “”;

// name of the database to use

//

String database = “IOT_Database”;

// name of the table that will be created

String table = “”;

// connect to database of server “l(fā)ocalhost”

dbconnection = new MySQL( this, “l(fā)ocalhost”, database, user, pass );

port = new Serial(this, Serial.list()[0], 9600); // initializing the object by assigning a port and baud rate (must match that of Arduino)

port.clear(); // function from serial library that throws out the first reading, in case we started reading in the middle of a string from Arduino

serial = port.readStringUntil(end); // function that reads the string from serial port until a println and then assigns string to our string variable (called ‘serial’)

serial = null;

}

void draw()

{

background(255);

textFont(f,24);

fill(0);

text(“Total Amount Rs:”,400,400);

text(Total,585,400);

data();

while (port.available() 》 0)

{

//as long as there is data coming from serial port, read it and store it

serial = port.readStringUntil(end);

}

if (serial != null)

{

prev=curr;

curr=a[1];

a = split(serial, ‘,’); //a new array (called ‘a(chǎn)’) that stores values into separate cells (separated by commas specified in your Arduino program

if((curr).equals(prev))

{

//

}

else

{

//println(“curr”,curr);

//println(“Prev”,prev);

function();

}

}

}

void function()

{

if ( dbconnection.connect() )

{

// now read it back out

//

dbconnection.query( “SELECT * from rfid where ID=”+a[0]+“” );

while (dbconnection.next())

{

ID = dbconnection.getInt(“ID”);

token = dbconnection.getInt(“token”);

Amount = dbconnection.getInt(“Amount”);

}

if(token==0)

{

println(“Ok”);

textFont(f,54);

fill(255,0,0,160);

text(“Unknown Item Detected”,50,300);

delay(2000);

}

else if(token==1)

{

Total=Total+Amount;

dbconnection.query(“update rfid set token=2 where ID=”+a[0]+“” );

println(“Ok”);

textFont(f,24);

fill(255,0,0,160);

//text(“Item Added”,10,30);

delay(1000);

}

else if(token==2)

{

Total=Total-Amount;

dbconnection.query(“update rfid set token=1 where ID=”+a[0]+“” );

println(“Ok”);

textFont(f,24);

fill(255,0,0,160);

//text(“Item Removed”,10,30);

delay(1000);

}

else

{

}

dbconnection.close();

}

else

{

// connection failed !

}

}

void data()

{

int position=100;

if ( dbconnection.connect() )

{

dbconnection.query( “SELECT * from rfid where token=2”);

while (dbconnection.next())

{

Name = dbconnection.getString(“Name”);

Amount = dbconnection.getInt(“Amount”);

textFont(f,24);

fill(0,0,255,160);

text(Name,10,position);

fill(0,0,0,160);

text(Amount,215,position);

position=position+30;

}

}

dbconnection.close();

}

第5步:執(zhí)行程序

通過(guò)單擊運(yùn)行按鈕運(yùn)行程序,請(qǐng)關(guān)閉彈出窗口,關(guān)閉窗口將停止執(zhí)行,并在以下查詢(xún)中查看在MySQL中存儲(chǔ)的數(shù)據(jù)。..

責(zé)任編輯:wv

聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • RFID
    +關(guān)注

    關(guān)注

    392

    文章

    6448

    瀏覽量

    242485
  • 應(yīng)用程序
    +關(guān)注

    關(guān)注

    38

    文章

    3337

    瀏覽量

    59040
  • Arduino
    +關(guān)注

    關(guān)注

    190

    文章

    6498

    瀏覽量

    192201
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    單片機(jī)實(shí)例:RC522無(wú)線射頻項(xiàng)目資料

    單片機(jī)實(shí)例:RC522無(wú)線射頻項(xiàng)目資料,推薦下載!
    發(fā)表于 06-03 22:09

    ESP32驅(qū)動(dòng)MFRC522 RFID模塊讀寫(xiě)IC卡數(shù)據(jù)

    本文將介紹ESP32開(kāi)發(fā)板驅(qū)動(dòng)MFRC522 RFID模塊,讀取RFID卡原始數(shù)據(jù)、獲取RFID卡的UID,并將個(gè)人數(shù)據(jù)添加到RFID卡中。
    的頭像 發(fā)表于 05-28 15:52 ?240次閱讀
    ESP32驅(qū)動(dòng)MFRC<b class='flag-5'>522</b> <b class='flag-5'>RFID</b>模塊讀寫(xiě)IC卡數(shù)據(jù)

    hyper-v 備份,hyper-v怎樣進(jìn)行虛擬機(jī)的創(chuàng)建

    車(chē):powershellEnable-WindowsOptionalFeature-Online-FeatureNameMicrosoft-Hyper-V-All系統(tǒng)提示重啟時(shí),選擇“是”。 ? ?創(chuàng)建虛擬機(jī),打開(kāi)Hyper-V管理器,按“Win+Q”組合鍵,輸入“Hyper-V管理器”,然后打開(kāi)該
    的頭像 發(fā)表于 02-05 14:54 ?447次閱讀
    hyper-v 備份,hyper-v<b class='flag-5'>怎樣</b>進(jìn)行虛擬機(jī)的<b class='flag-5'>創(chuàng)建</b>

    ANACONDA——關(guān)于發(fā)布數(shù)據(jù)應(yīng)用程序的新簡(jiǎn)單方法

    與 Anaconda 的云筆記本服務(wù)無(wú)縫集成,為用戶(hù)提供了種輕松共享筆記本結(jié)果的方式,并讓其他人也可以隨意的訪問(wèn)它們。 下面我們來(lái)了解關(guān)于這項(xiàng)新功能的實(shí)際應(yīng)用: 這項(xiàng)功能與 Panel 的多功能性相結(jié)合,將徹底改變您發(fā)布數(shù)據(jù)應(yīng)用程序的方式。使用這個(gè)強(qiáng)大的工具,為共享和協(xié)
    的頭像 發(fā)表于 01-17 11:39 ?431次閱讀
    ANACONDA——關(guān)于發(fā)布數(shù)據(jù)<b class='flag-5'>應(yīng)用程序</b>的新<b class='flag-5'>簡(jiǎn)單</b>方法

    RC522不定時(shí)檢測(cè)不到信號(hào)

    這是個(gè)插卡取電使用的RC522射頻電路,過(guò)幾天就死機(jī)了樣,有沒(méi)有大神給點(diǎn)意見(jiàn) 單片機(jī)用的是STC15W404AS
    發(fā)表于 01-14 13:42

    android手機(jī)上emulate應(yīng)用程序的方法

    。以下是些在Android手機(jī)上模擬應(yīng)用程序的具體方法和步驟: 、使用Android Studio中的模擬器 安裝Android Studio : 首先,你需要在電腦上安裝Android
    的頭像 發(fā)表于 12-05 15:33 ?1217次閱讀

    AWTK-WEB 快速入門(mén)(1) - C 語(yǔ)言應(yīng)用程序

    導(dǎo)讀AWTK可以使用相同的技術(shù)棧開(kāi)發(fā)各種平臺(tái)的應(yīng)用程序。有時(shí)我們需要使用Web界面與設(shè)備進(jìn)行交互,本文介紹下如何使用C語(yǔ)言開(kāi)發(fā)AWTK-WEB應(yīng)用程序。用AWTKDesigner新建
    的頭像 發(fā)表于 11-27 11:46 ?724次閱讀
    AWTK-WEB 快速入門(mén)(1) - C 語(yǔ)言<b class='flag-5'>應(yīng)用程序</b>

    使用OpenVINO? ElectronJS中創(chuàng)建桌面應(yīng)用程序

    的用戶(hù)體驗(yàn)。 1 應(yīng)用程序概覽:簡(jiǎn)單的背景虛化方法 這個(gè)演示展示了如何在 Node.js 環(huán)境中使用 OpenVINO 工具包實(shí)現(xiàn)背景虛化,并通過(guò) Electron.js 創(chuàng)建的直
    的頭像 發(fā)表于 11-25 11:35 ?580次閱讀
    使用OpenVINO? ElectronJS中<b class='flag-5'>創(chuàng)建</b>桌面<b class='flag-5'>應(yīng)用程序</b>

    RC522 RFID實(shí)驗(yàn)的小系統(tǒng)板接線說(shuō)明

    6.RC522 RFID實(shí)驗(yàn)的小系統(tǒng)板接線說(shuō)
    發(fā)表于 11-22 16:36 ?0次下載

    Air780EP之RC522開(kāi)發(fā)板,你了解嗎?

    ; LuatOS-Soc固件獲取 https://gitee.com/openLuat/LuatOS/releases 、環(huán)境準(zhǔn)備 1.1 Air780EP開(kāi)發(fā)板套 1.2 rc522實(shí)物
    的頭像 發(fā)表于 11-03 08:21 ?660次閱讀
    Air780EP之<b class='flag-5'>RC522</b>開(kāi)發(fā)板,你了解嗎?

    4G通信先鋒:Air780EP開(kāi)發(fā)板與RC522的結(jié)合

    最近,直有朋友問(wèn)我Air780EP開(kāi)發(fā)板RC522, 今天抽空給大家展示下示例: 本文檔適用于Air780EP開(kāi)發(fā)板 關(guān)聯(lián)文檔和使用工具
    的頭像 發(fā)表于 10-29 14:29 ?494次閱讀
    4G通信先鋒:Air780EP開(kāi)發(fā)板與<b class='flag-5'>RC522</b>的結(jié)合

    低功耗4G模組:Air780EP開(kāi)發(fā)板RC522實(shí)例

    開(kāi)發(fā)板套 1.2 rc522實(shí)物個(gè) ? 二、程序詳解 2.1 API說(shuō)明 2.1.1 設(shè)置并啟用SPI spi.setup(id, cs
    的頭像 發(fā)表于 10-21 17:01 ?588次閱讀
    低功耗4G模組:Air780EP開(kāi)發(fā)板<b class='flag-5'>RC522</b>實(shí)例

    SI522A 與 恩智浦 RC522 刷卡對(duì)比

    去年偶然拿到顆SI522的低功耗IC,再自動(dòng)尋卡LPCD上取得了不凡的成績(jī),LPCD低功耗自動(dòng)尋卡功能只有4.5uA.SI522A針對(duì)SI522上的ACD低功耗自動(dòng)尋卡功能做了全新的
    發(fā)表于 09-30 14:19

    可以在單個(gè)esp8266上安裝兩個(gè)NON OS SDK應(yīng)用程序嗎?

    個(gè)簡(jiǎn)單的問(wèn)題。我可以在單個(gè) esp8266 上安裝兩個(gè) NON OS SDK 應(yīng)用程序嗎?我的自定義引導(dǎo)加載
    發(fā)表于 07-19 07:28